AngularJS - Trigger when radio button is selected

前端 未结 7 1648
有刺的猬
有刺的猬 2020-11-30 21:13

I searched and tried many ng-xxxx kind of options but couldn\'t find the one.. I just want to call some function in the controller when radio button is selected.

So

7条回答
  •  渐次进展
    2020-11-30 21:24

    In newer versions of angular (I'm using 1.3) you can basically set the model and the value and the double binding do all the work this example works like a charm:

    angular.module('radioExample', []).controller('ExampleController', ['$scope', function($scope) {
      $scope.color = {
        name: 'blue'
      };
    }]);
    
    
    
    
    Red
    Green
    Blue
    color = {{color.name}}

提交回复
热议问题