Skip to content
This repository was archived by the owner on May 25, 2019. It is now read-only.

Commit b1b30e4

Browse files
committed
Merge pull request #81 from angular-ui/fix-digest-in-progress
fix: digest in progress
2 parents 7188ecc + 645d6e5 commit b1b30e4

File tree

2 files changed

+2
-2
lines changed

2 files changed

+2
-2
lines changed

src/ui-codemirror.js

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -127,8 +127,7 @@ function uiCodemirrorDirective($timeout, uiCodemirrorConfig) {
127127
codemirror.on('change', function(instance) {
128128
var newValue = instance.getValue();
129129
if (newValue !== ngModel.$viewValue) {
130-
// Changes to the model from a callback need to be wrapped in $apply or angular will not notice them
131-
scope.$apply(function() {
130+
scope.$applyAsync(function() {
132131
ngModel.$setViewValue(newValue);
133132
});
134133
}

test/codemirror.spec.js

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -305,6 +305,7 @@ describe('uiCodemirror', function() {
305305

306306
// change should be called when user changes the input.
307307
codemirror.setValue('baz');
308+
scope.$apply();
308309
expect(scope.change.calls.count()).toBe(1);
309310
expect(scope.change).toHaveBeenCalledWith();
310311
});

0 commit comments

Comments
 (0)