Reputation: 73
In jQuery I would do something like:
$( ".radio-buttons" ).change(function() {
..
});
How would I do the same in Angular JS
Upvotes: 0
Views: 2394
Reputation: 588
There are 2 ways to monitor a radio button changes ,
First is to use ng-change along with the radio button,
</label><input type="radio" ng-model="radioValue" ng-change="invokeChangeFunction()" />Yes</label>
In controller ,
$scope.invokeChangeFunction = function() {
console.log($scope.value);
}
Second method is using $watch for ng-model,
$scope.$watch('radioValue', function(value) {
console.log(value);
});
Upvotes: 1
Reputation: 3944
In HTML
<input type="checkbox" ng-change="change()">
In controller
$scope.change=function(){
//your logic
}
Upvotes: 0