user3056656 user3056656 - 27 days ago 6
AngularJS Question

Call Angular-function upon $scope-variable change

I am new to AngularJS and trying to set up a function that gets called upon whenever a variable is changed.

Currently I have a dropdown-menu, with ng-model bound to a $scope.userRating. And I am trying to get a function that gets called immediately when the user changes the value using the dropdown.

I have been looking at $watch, but not quite sure on how to get it to work. I also tried to make a ng-click function on the in the html, but ng-clicks don't seem to trigger.

Answer Source

You should use $watch . Example-

//do your code

Here on the change of variable 'modalVarible' this watch will be called.