ng-checked and ng-change radio button not work together - angularjs

前端 未结 4 2059
梦谈多话
梦谈多话 2020-12-16 17:37

http://plnkr.co/edit/RP9SpO1qGjn5Ua6pZJ3D?p=preview

js

angular.module(\"sampleapp\", []).controller(\'samplecontroller\', function($scope,$rootScope)         


        
4条回答
  •  失恋的感觉
    2020-12-16 18:31

    Use default values and everything will work like a charm, no need to $watch scope or anything... and Yes you need ng-model

    • ng-model - does all work
    • ng-checked - makes sure you have CHECKED attribute present
    • ng-change - will trigger your function on-Change

    HTML example:

    
    
    {{ row.active }}
    

    JS optional:

    $scope.update = function(row) {
        console.log('row.active');
    }
    

提交回复
热议问题