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

update ngModel on IDE change #124

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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