From 7517bd6a21b875689709900b5c777970a233b2fa Mon Sep 17 00:00:00 2001 From: Outsider Date: Tue, 29 Mar 2016 03:21:39 +0900 Subject: [PATCH] fix reactivating issue when ngModel is updated initial watch activate summernote editor whenever contents are updated, so if user enter key, ngModelUpdate occured multiple time. It decrease performance. fixed #117 , #119 --- src/angular-summernote.js | 7 +++---- 1 file changed, 3 insertions(+), 4 deletions(-) diff --git a/src/angular-summernote.js b/src/angular-summernote.js index dca6f75..cced9e2 100644 --- a/src/angular-summernote.js +++ b/src/angular-summernote.js @@ -21,7 +21,7 @@ angular.module('summernote', []) } summernoteConfig.callbacks = summernoteConfig.callbacks || {}; - + if (angular.isDefined($attrs.onInit)) { summernoteConfig.callbacks.onInit = function(evt) { $scope.init({evt:evt}); @@ -194,9 +194,8 @@ angular.module('summernote', []) }); summernoteController.activate(scope, element, ngModel); } else { - scope.$watch(function() { - return ngModel.$viewValue; - }, function(value) { + var clearWatch = scope.$watch(function() { return ngModel.$viewValue; }, function(value) { + clearWatch(); element.append(value); summernoteController.activate(scope, element, ngModel); }, true);