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:
<html ng-app="root">
The controller looks like this:
angular.module("root", [])
Note: The directives are named in camelCase but are written in hyphen-delimited lower case when applied in html elements as attributes. Also, there can only be one ngApp directive in the html document.
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.