Ng-Init-4

 

In this example, We are setting a variable value as true and assigning the same variable as ng-model of checkbox "isCheck" is a angular variable with ng-model of checkbox. So by default the checkbox will be selected

 
 
 
<!DOCTYPE html> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <title>Welcome to LearnKode - A code learning platform</title> <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.4.2/angular.min.js"></script> </head> <body ng-app> <div> <div class="container" ng-init="isCheck=true"> Are you 18+ <input type="checkbox" ng-model="isCheck" /> </div> </div> </body> </html>
Output