This directive automatically initializes the AngularJS application on page load.Įxample: This example illustrates the implementation of the ng-app directive in AngularJS. ng-app : The ng-app directive is used to define the root element of an AngularJS application. Some directive components are discussed below:ġ. Please refer to the AngularJS Directives Complete Reference article for a detailed description of Directives.ĭirective Components: The AngularJS directives extend the attribute with the prefix ng. Directive classes, like component classes, can implement life-cycle hooks to influence their configuration and behavior.When AngularJS bootstraps your application, the HTML compiler traverses the DOM matching directives against the DOM elements. Much like you create controllers and services, you can create your own directives for AngularJS to use. It is used to give more power to HTML by helping them with the new syntax. AngularJS comes with a set of these directives built-in, like ngBind, ngModel, and ngClass.A directive is activated when the same element or matching element is there in front.It gives support to creating custom directives for different types of elements.A directive can be defined using some functions which are: Element name, Attribute, Class, and Comment. AngularJS has a set of built-in directives which offers functionality to the applications.
Simple AngularJS allows extending HTML with new attributes called Directives.
ISRO CS Original Papers and Official Keys The scope allows AngularJS to ensure that another object can’t accidentally change an object.GATE CS Original Papers and Official Keys.