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.
You should use $watch . Example-
$scope.$watch('modalVarible',function(newVal,oldVal){
//do your code
}
Here on the change of variable 'modalVarible' this watch will be called.
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With