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

Commit

Permalink
update ngModel on IDE change
Browse files Browse the repository at this point in the history
  • Loading branch information
Ryan A. Johnson committed Sep 19, 2015
1 parent 4c62a97 commit 5aac070
Show file tree
Hide file tree
Showing 2 changed files with 22 additions and 0 deletions.
4 changes: 4 additions & 0 deletions src/ui-ace.js
Original file line number Diff line number Diff line change
Expand Up @@ -272,6 +272,10 @@ angular.module('ui.ace', [])
ngModel.$render = function () {
session.setValue(ngModel.$viewValue);
};

acee.on('change', function () {
ngModel.$setViewValue(acee.getValue());
});
}

// Listen for option updates
Expand Down
18 changes: 18 additions & 0 deletions test/ace.spec.js
Original file line number Diff line number Diff line change
Expand Up @@ -284,6 +284,24 @@ describe('uiAce', function () {
//
expect(scope.foo).toBe('baz');
});

it('should update the model if text inserted programmatically', function () {
$compile('<div ui-ace ng-model="foo">')(scope);
scope.$apply('foo = "bar"');

_ace.insert('baz ');

expect(scope.foo).toBe('baz bar');
});

it('should update the model if text removed programmatically', function () {
$compile('<div ui-ace ng-model="foo">')(scope);
scope.$apply('foo = "baz bar"');

_ace.removeWordRight();

expect(scope.foo).toBe(' bar');
});
});

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

0 comments on commit 5aac070

Please sign in to comment.