I am trying to create a directive for color picker and value of ngModel value is not being updated. Any idea whats going wrong?
Here is my code:
.directive('colpkr', [function () {
return {
restrict: 'A',
scope: {
theme : "@theme",
ngModel : "="
},
link: function postLink(scope, iElement, iAttrs) {
theme = scope.theme || "light";
$(iElement).colpick({
layout:'hex',
submit:0,
colorScheme:theme,
onChange:function(hsb, hex, rgb, iElement, bySetColor) {
if(!bySetColor) scope.ngModel = '#' + hex;
}
});
}
};
}]);
require
rather thanscope