Angularjs : Why My Watch Is Not Working
I am trying to put a watch on a variable, so that if it's value changes I call the rest service and get updated count. Here is how my code looks like function myController($scope,
Solution 1:
You need to reference it in the $scope
.
$scope.$watch('abc', $scope.getAbcCnt);
If you were to declare your function without the $scope
prefix your existing call would work, but you would not be able to access the function from the view. If you don't need to access the function from the view, you can declare the function without the $scope
and keep your existing $watch
statement.
Post a Comment for "Angularjs : Why My Watch Is Not Working"