Reputation: 6151
I have an input with type color defined in my controller scope:
HTML:
<div ng-controller="MyCtrl">
<input type="color" value="#f0f0f0" />
<input type="color" value={{getColor()}} />
</div>
JS:
function MyCtrl($scope) {
$scope.getColor = function () {
return "#f0f0f0";
};
}
The problem is the color don't get updated when its set by Angular, although when inspecting I see this:
See: FIDDLE.
How to update html5 input color dynamically?
Upvotes: 2
Views: 6104
Reputation: 1
You don`t even need a $watch, just a $timeout.
function MyCtrl($scope, $timeout) {
$timeout(() => {
$scope.mycolor = "#f0f0f0";
})
}
working fiddle http://jsfiddle.net/3ukL3suf/
Upvotes: 0