diff --git a/angular-redactor-9.x.js b/angular-redactor-9.x.js index fe6e0c3..9a90a0d 100644 --- a/angular-redactor-9.x.js +++ b/angular-redactor-9.x.js @@ -21,13 +21,18 @@ // Expose scope var with loaded state of Redactor scope.redactorLoaded = false; - + + var assignPristine = true; var updateModel = function updateModel(value) { // $timeout to avoid $digest collision $timeout(function() { - scope.$apply(function() { + if(value) { ngModel.$setViewValue(value); - }); + if(assignPristine) { + ngModel.$setPristine(); + assignPristine = false; + } + } }); }, options = { diff --git a/angular-redactor.js b/angular-redactor.js index 5a106ae..ddd7a3c 100644 --- a/angular-redactor.js +++ b/angular-redactor.js @@ -21,13 +21,18 @@ // Expose scope var with loaded state of Redactor scope.redactorLoaded = false; - + + var assignPristine = true; var updateModel = function updateModel(value) { // $timeout to avoid $digest collision $timeout(function() { - scope.$apply(function() { + if(value) { ngModel.$setViewValue(value); - }); + if(assignPristine) { + ngModel.$setPristine(); + assignPristine = false; + } + } }); }, options = { @@ -72,4 +77,3 @@ }; }]); })(); -