What is the role of ng-app, ng-init and ng-model directives in AngularJS ?
In this article, we will learn about the directives in AngularJS & explore the roles of various directives such as ng-app, ng-init & ng-model in angularJS.
The AngularJS directive is a command that gives HTML documents new functionality. When we use the AngularJS directives, it will first find all the directives in the HTML document and then parse the HTML document accordingly.
ng-app: The ng-app is the directive that is used to define the AngularJS application. By placing this in the HTML document, it indicates that this is an AngularJS application.
ng-init: The ng-init is the directive that is used for the initialization of the application data. In a simple way, it is used as a local variable in AngularJS. Sometimes we need some local data in your application, so by using the ng-init directive it can be achieved.
ng-model: The ng-model is the directive that is used to bind the value of the HTML control to application data. It is used to bind the data in the HTML document.