diff --git a/checklist-model.js b/checklist-model.js index 446f910..15a1205 100644 --- a/checklist-model.js +++ b/checklist-model.js @@ -26,7 +26,7 @@ angular.module('checklist-model', []) arr.push(item); } return arr; - } + } // remove function remove(arr, item, comparator) { @@ -67,7 +67,7 @@ angular.module('checklist-model', []) comparator = function (a, b) { return a[comparatorExpression] === b[comparatorExpression]; }; - + } else { comparator = $parse(attrs.checklistComparator)(scope.$parent); } @@ -75,9 +75,6 @@ angular.module('checklist-model', []) // watch UI checked change scope.$watch(attrs.ngModel, function(newValue, oldValue) { - if (newValue === oldValue) { - return; - } var current = getter(scope.$parent); if (angular.isFunction(setter)) { if (newValue === true) { @@ -91,7 +88,7 @@ angular.module('checklist-model', []) checklistChange(scope); } }); - + // declare one function to be used for both $watch functions function setChecked(newArr, oldArr) { scope[attrs.ngModel] = contains(newArr, value, comparator);