javascript - Angular: obtain cause of a $watch to be triggered -
a short question: in angular, there way whatsoever obtain "root cause" of $watch
triggered?
let's have following javascript code:
$scope.$watch("foo", function(value){ // here i'd know if change triggered // due change in ngmodel or through ngclick }; $scope.changefoo = function(){ $scope.foo = "bar" };
and html:
<input ng-model="foo"> <button ng-click="changefoo()">change foo > bar</button>
in $watch
i'd know caused fired. in case, change in ngmodel
or value changed in function of ngclick
?
no, there no way current implementation.
$watch
triggered running function called $apply
. function doesn't know triggered it.
you going need perspective fix problem.
Comments
Post a Comment