<input type="checkbox" name="customPermissions[]" ng-model="form.customPermissions.examsList" value="examsList" ng-init="form.customPermissions.examsList=true"> {{phrase.examsList}}
我想保持默認複選框的值,如上所述嘗試,但它不起作用。 在此先感謝。在angularJs中默認檢查的複選框值
<input type="checkbox" name="customPermissions[]" ng-model="form.customPermissions.examsList" value="examsList" ng-init="form.customPermissions.examsList=true"> {{phrase.examsList}}
我想保持默認複選框的值,如上所述嘗試,但它不起作用。 在此先感謝。在angularJs中默認檢查的複選框值
使用ng-checked
真正
<input ng-checked = "true" type="checkbox" name="customPermissions[]" ng-model="form.customPermissions.examsList" value="examsList" ng-init="form.customPermissions.examsList=true"> {{phrase.examsList}}
或者你可以指定NG-模型值true initialy這樣的演示
angular.module("app",[])
.controller("ctrl",function($scope){
\t $scope.checkVal = true;
})
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.23/angular.min.js"></script>
<div ng-app="app" ng-controller="ctrl">
check : {{checkVal}}
<input type="checkbox" name="customPermissions[]" ng-model="checkVal" value="examsList" ng-init="form.customPermissions.examsList=true"> sample
</div>
謝謝@sachila。 – Cliffs
沒有問題。如果這有助於確保檢查是正確的答案 –
<html ng-app ng-controller="testcontroller">
<input type="checkbox" ng-model="lookup" value="1">Default Checked</input>
<input type="checkbox" ng-model="lookup1" value="1">Default UnChecked</input>
</html>`
function testcontroller($scope){
$scope.lookup = true;
$scope.lookup1 = false;
}`
嘗試,這也得到預期的js小提琴鏈接....
給ng-model複選框,並在控制器中指定想要選擇的ng-model值。 – Jenny