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

Commit 645d6e5

Browse files
43081jdouglasduteil
authored andcommitted
fix: digest in progress
Use applyAsync instead of apply, to avoid digest in progress issues Close #73 #74 #66
1 parent 2f789f6 commit 645d6e5

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)