2
<input  type="checkbox" name="customPermissions[]" ng-model="form.customPermissions.examsList" value="examsList" ng-init="form.customPermissions.examsList=true"> {{phrase.examsList}}

I want to keep checkbox value as checked by default,tried as above but it doesn't work. Thanks in advance.

1
  • give ng-model to checkbox, and assign ng-model value in controller that you want to be selected. Commented Mar 9, 2017 at 7:06

2 Answers 2

1

use ng-checkedtrue

<input ng-checked = "true"  type="checkbox" name="customPermissions[]" ng-model="form.customPermissions.examsList" value="examsList" ng-init="form.customPermissions.examsList=true"> {{phrase.examsList}}

Or you can assign ng-model value true initialy like this Demo

angular.module("app",[])
.controller("ctrl",function($scope){
	$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>

Sign up to request clarification or add additional context in comments.

1 Comment

no prob. if this helped make sure to check as right answer
1
<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;
 }`

Try this also get expected in the js fiddle link....

http://jsfiddle.net/kn373r5o/

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.