Skip to content
Related Articles

Related Articles

Improve Article
Save Article
Like Article

AngularJS | ng-init Directive

  • Last Updated : 28 Mar, 2019

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.


<element ng-init = "expression">

Example: In this example, we initialize an array of string.

        <title>AngularJS ng-init Directive</title>
            <h1 style = "color:green">GeeksforGeeks
            <h2>ng-init directive</h2>
            <div ng-app="" ng-init="sort=['quick sort', 'merge sort',
             'bubble sort']">
             Sorting techniques:
            <li>{{ sort[0] }} </li>
            <li>{{ sort[1] }} </li>
            <li>{{ sort[2] }} </li>


My Personal Notes arrow_drop_up
Recommended Articles
Page :

Start Your Coding Journey Now!