Skip to content
This repository was archived by the owner on Sep 8, 2020. It is now read-only.

Commit 852433b

Browse files
author
Ryan A. Johnson
committed
update ngModel on IDE change
1 parent 4c62a97 commit 852433b

File tree

2 files changed

+22
-0
lines changed

2 files changed

+22
-0
lines changed

src/ui-ace.js

+4
Original file line numberDiff line numberDiff line change
@@ -272,6 +272,10 @@ angular.module('ui.ace', [])
272272
ngModel.$render = function () {
273273
session.setValue(ngModel.$viewValue);
274274
};
275+
276+
acee.on('change', function (event) {
277+
ngModel.$setViewValue(acee.getValue());
278+
});
275279
}
276280

277281
// Listen for option updates

test/ace.spec.js

+18
Original file line numberDiff line numberDiff line change
@@ -284,6 +284,24 @@ describe('uiAce', function () {
284284
//
285285
expect(scope.foo).toBe('baz');
286286
});
287+
288+
it('should update the model if text inserted programmatically', function () {
289+
$compile('<div ui-ace ng-model="foo">')(scope);
290+
scope.$apply('foo = "bar"');
291+
292+
_ace.insert('baz ');
293+
294+
expect(scope.foo).toBe('baz bar');
295+
});
296+
297+
it('should update the model if text removed programmatically', function () {
298+
$compile('<div ui-ace ng-model="foo">')(scope);
299+
scope.$apply('foo = "baz bar"');
300+
301+
_ace.removeWordRight();
302+
303+
expect(scope.foo).toBe(' bar');
304+
});
287305
});
288306

289307
describe('when the model is undefined/null', function () {

0 commit comments

Comments
 (0)