Google News
logo
AngularJS - Interview Questions
What is ng-init directive ?
The ng-init directive defines initializes an AngularJS application. It defines the initial values for an AngularJS application. In following example, we'll initialize an array of countries. We're using JSON syntax to define array of countries.

<div ng-app="" ng-init="countries = [{locale:'en-US',name:'United States'}, 
{locale:'en-IND',name:'India'}, {locale:'en-GB',name:'United Kingdom'}, 
{locale:'en-PAK',name:'Pakistan'}, {locale:'en-AUS',name:'Australia'}]">
  .....
  .....
</div>

Advertisement