AngularJS - Trigger when radio button is selected

前端 未结 7 1652
有刺的猬
有刺的猬 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:48

    Should use ngChange instead of ngClick if trigger source is not from click.

    Is the below what you want ? what exactly doesn't work in your case ?

    var myApp = angular.module('myApp', []);
    
    function MyCtrl($scope) {
        $scope.value = "none" ;
        $scope.isChecked = false;
        $scope.checkStuff = function () {
            $scope.isChecked = !$scope.isChecked;
        }
    }
    
    
    
    {{value}} isCheck:{{isChecked}}

提交回复
热议问题