It sounds that a string
containing some characters like a colon can't be observed by angular's $watch
function.
Here's my plunker reproducing the case (console printing the error when the html page opens): http://plnkr.co/edit/w9ItkHZmy4khzYcWHD2A
How to deal with this issue?
You should use $watch
with a string that represents a property in your scope, and not an actually object.
Just change the $watch
to this:
$scope.$watch('myHourString', function (hour) {
console.log("im ok now");
angular.noop();
});
Try with this :
$scope.$watch('myHourString', function (hour) {
angular.noop();
});
See working plunker here
The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.