Ng-Init-1

 

Ng-init is used to initialization. In this example of ng-init, test variable is bound with textbox and it is initialized with value "LearnKode" using ng-init directive as ng-init="test='LearnKode'". So wherever the variable is being used, will be set to "LearnKode" . See the code snippet:

 
 
 
<!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 ng-init="test='LearnKode'"> My WebSite <input type="text" ng-model="test" /> </div> </div> </body> </html>
Output