AngularJS | ng-init Directive
The ng-init directive is used to initialize an AngularJS Application data. It defines the initial value for an AngularJS application and assigns values to the variables.
The ng-init directive defines initial values and variables for an AngularJS application.
Syntax:
<element ng-init = "expression"> ... </element>
Example: In this example, we initialize an array of string.
<html> angular.min.js"></script> <head> <title>AngularJS ng-init Directive</title> </head> <body> <h1 style = "color:green">GeeksforGeeks <h2>ng-init directive</h2> <div ng-app="" ng-init="sort=['quick sort', 'merge sort', 'bubble sort']"> Sorting techniques: <ul> <li>{{ sort[0] }} </li> <li>{{ sort[1] }} </li> <li>{{ sort[2] }} </li> </ul> </div> </body></html> |
Output:



