Skip to content

Commit eefaeae

Browse files
committed
Update to fix a bug where the minicolor setting would not update when the model referenced an object indirectly (such as the case when one uses value[0], for example, where element 0 can change without value changing.) In such cases, using to monitor the value yields the proper behaviour
1 parent 78e04c2 commit eefaeae

File tree

1 file changed

+3
-5
lines changed

1 file changed

+3
-5
lines changed

angular-minicolors.js

+3-5
Original file line numberDiff line numberDiff line change
@@ -43,14 +43,12 @@ angular.module('minicolors').directive('minicolors', ['minicolors', '$timeout',
4343
};
4444

4545
//what to do if the value changed
46-
ngModel.$render = function () {
47-
46+
scope.$watch(function () { return ngModel.$viewValue; }, function (newValue) {
4847
//we are in digest or apply, and therefore call a timeout function
4948
$timeout(function() {
50-
var color = ngModel.$viewValue;
51-
element.minicolors('value', color);
49+
element.minicolors('value', newValue);
5250
}, 0, false);
53-
};
51+
});
5452

5553
//init method
5654
var initMinicolors = function () {

0 commit comments

Comments
 (0)