From 491369a9d508c28ad880ad707e35c3d827c0a71a Mon Sep 17 00:00:00 2001 From: rebornix Date: Thu, 8 Jan 2015 02:43:48 +0100 Subject: [PATCH] fix: ngModel update Closes #77 --- src/ui-ace.js | 9 ++++----- 1 file changed, 4 insertions(+), 5 deletions(-) diff --git a/src/ui-ace.js b/src/ui-ace.js index ac79fcd..dddc8a8 100644 --- a/src/ui-ace.js +++ b/src/ui-ace.js @@ -218,11 +218,10 @@ angular.module('ui.ace', []) onChange: function (callback) { return function (e) { var newValue = session.getValue(); - if (newValue !== scope.$eval(attrs.value) && !scope.$$phase && !scope.$root.$$phase) { - if (ngModel !== null) { - scope.$apply(function () { - ngModel.$setViewValue(newValue); - }); + if (newValue !== scope.$eval(attrs.value)) { + if (angular.isDefined(ngModel)) { + ngModel.$setViewValue(newValue); + !scope.$$phase && !scope.$root.$$phase && scope.$digest(); } executeUserCallback(callback, e, acee); }