angularjs - How to trigger a watch when i click my button -
how can $watch()
on button , trigger $watch()
when press button...?
html:
<button style="margin-left:10px;" class="btn btn-danger btn-xs"> re-init tableau </button>
js:
scope.$watch('[]', function () {}, true);
thx.
you add ngclick
on button:
<button ng-click="addwatch()" style="margin-left:10px;" class="btn btn-danger btn-xs"> re-init tableau </button>
and in controller:
$scope.addwatch = function(){ if( !$scope.iswatchadded ) { $scope.$watch('[]', function () {}, true); $scope.iswatchadded = true; } }
this add once watch
expression
Comments
Post a Comment