TinYTie
TinYTie

Reputation: 73

Angular equivalent of Radio Button Change Event

In jQuery I would do something like:

$( ".radio-buttons" ).change(function() {
 ..
});

How would I do the same in Angular JS

Upvotes: 0

Views: 2394

Answers (2)

Janaki Sathiyamurthy
Janaki Sathiyamurthy

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

Shubham Nigam
Shubham Nigam

Reputation: 3944

In HTML

<input type="checkbox" ng-change="change()">

In controller

 $scope.change=function(){
    //your logic
    }

Upvotes: 0

Related Questions