The most used directives in AngularJS are ng-app, ng-init and ng-model. Lets discuss about the each of the directives in detail:
- ngApp : In AngularJS application we need to tell the module to be used as a ‘root module’. This is done by adding the ngApp directive to the html element in the form of an attribute. In other words, ngApp directive initializes an AngularJS application as shown below:
The controller looks like this:
Hence, ng-app is written in hyphen-delimited format when applied in html element. In addition, the value of element needs to be the name of the root module.