【发布时间】:2015-05-12 20:52:28
【问题描述】:
当我的模型值为true 时,我希望在加载时选择单选按钮,但它会发生相反的情况。所有false 模型都被选中。如何解决这个问题。
http://plnkr.co/edit/DIYm4vBM3srdS61K6EPA?p=preview
angular.module('radioExample', [])
.controller('ExampleController', ['$scope',
function($scope) {
$scope.kind = [{
name: 'task',
selected: false
}, {
name: 'bug',
selected: false
}, {
name: 'other',
selected: true
}, {
name: 'rfe',
selected: false
}]
$scope.$watch('kind', function() {
console.log('changed', JSON.stringify($scope.kind, null, 2))
}, true)
}
]);
【问题讨论】: