我有一個使用ng-repeat顯示的複選框列表,現在我需要根據特定值禁用某些複選框複選框被選中。Angular根據值禁用ng-repeat複選框
checkbox display code
<div class="checkbox">
<label ng-repeat="specific in specifications">
<input ng-click="onClick(specific, newObject[specific])" id="specifications_chk" value="{{specific}}" ng-model="newObject[specific]" type="checkbox">
{{specific}}
</label>
</div>
這裏我使用ng-click函數來禁用複選框。
This is my controller code:
$scope.onClick = function(sp, checked){
if(sp == 'Sofa_Cleaning' && checked === true){
angular.element(document.getElementById('specifications_chk'))[0].disabled = true;
}
if(sp == 'Sofa_Cleaning' && checked === false){
angular.element(document.getElementById('specifications_chk'))[0].disabled = false;
}
};
html view:
在控制器代碼
我能夠禁用僅第一個值(IndepthHomeCleaning)
,所以,我怎麼可以禁用Room_Cleaning, Kitchen_Cleaning,
和Carpet_cleaning
時Sofa_Cleaning
是checked
難道我堅持這一點,幫助將是非常讚賞
'ng-disabled'怎麼樣? – Rayon
我沒有想法返回多個值 – Nodemon
@Nodemon現在請檢查代碼, – byteC0de