我正在使用AngularJs(Angular 1),我需要使用複選框來選擇/取消選中所有其他複選框。AngularJs複選框,將在所有其他複選框上選中
現在我有這樣的:
<li ng-repeat="item in ctrl.items">
<input type="checkbox" ng-model="item.selected">{{item.name}}
</li>
然後,我有這個控制器:
ctrl.items = [
{
value: 0,
name: 'Select All/Unselect all other checkboxes',
selected: true
},
{
value: 1,
name: 'myCheckbox1',
selected: true
},
{
value: 2,
name: 'myCheckbox2',
selected: true
},
{
value: 3,
name: 'myCheckbox2',
selected: true
}
];
我怎樣才能讓這個第一個複選框基本上只是選擇/取消選擇所有其他checkbboxes ?
這將觸發任何選中的複選框上的操作,不僅僅是OP想要的第一個。 – rrd