1
有一個問題,在這裏的情況:
我想取消選中第二個複選框時,第一個複選框。
比方說,默認情況下這兩個複選框都被選中。當我點擊第二個複選框時,我希望第一個複選框也取消選中。AngularJs:無法取消複選框時,取消其他複選框
HTML:
<ion-checkbox ng-model="firstCheckbox">First Checkbox</ion-checkbox>
<ion-checkbox ng-model="secondCheckbox" ng-change="uncheckFirstCheckbox(secondCheckbox)">Second Checkbox</ion-checkbox>
JS:
$scope.uncheckFirstCheckbox = function(secondCheckbox) {
if(secondCheckbox.checked === false) {
$scope.firstCheckbox = false;
};
};
的$scope.firstCheckbox
把假的,但它在HTML保持取消選中。
我可以知道問題出在哪裏?
嘗試'如果($ scope.secondCheckbox!){$ scope.firstCheckbox = FALSE; };',不要傳遞$ scope在函數調用中的值作爲一個好習慣 – harishr
謝謝你的提示:) @entre –