http://plnkr.co/edit/RP9SpO1qGjn5Ua6pZJ3D?p=preview
js
angular.module("sampleapp", []).controller('samplecontroller', function($scope,$rootScope) {
$scope.radii = [
{id:.25, checked:false, name:"1/4 Mile"},
{id:.5, checked:false, name:"1/2 Mile"},
{id:1, checked:false, name:"1 Mile"},
{id:2, checked:true, name:"2 Mile"},
{id:3, checked:false, name:"3 Mile"},
{id:4, checked:false, name:"4 Mile"},
{id:5, checked:false, name:"5 Mile"}
];
$scope.handleRadioClick = function(){
alert();
};
});
和 html
<div class="radio">
<label>
<input type="radio" name="radius"
ng-change="handleRadioClick()"
ng-checked="radius.checked">
{{radius.name}}
</label>
</div>
</li>
注意“2 Mile”无线电输入是根据半径范围结构检查的。为什么 ng-change 不触发该功能?
如果我添加 ng-model,该函数会触发,但 ng-checked 不起作用。