AngularJS – Trigger when radio button is selected

There are at least 2 different methods of invoking functions on radio button selection:

1) Using ng-change directive:

<input type="radio" ng-model="value" value="foo" ng-change="newValue(value)">

and then, in a controller:

$scope.newValue = function(value) {

Here is the jsFiddle:

2) Watching the model for changes. This doesn’t require anything special on the input level:

<input type="radio" ng-model="value" value="foo">

but in a controller one would have:

$scope.$watch('value', function(value) {

And the jsFiddle:

Knowing more about your the use case would help to propose an adequate solution.

Leave a Comment