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

Popular posts from this blog

matlab - "Contour not rendered for non-finite ZData" -

delphi - Indy UDP Read Contents of Adata -

javascript - Any ideas when Firefox is likely to implement lengthAdjust and textLength? -