Home » AngularJS ng-init Directive

AngularJS ng-init Directive

by Online Tutorials Library

AngularJS ng-init Directive

The AngularJS ng-init directive facilitates you to evaluate the given expression in the current scope. Ng-controller is preferred over ng-init because the ng-init directive can add some unnecessary logic into the scope.

It is supported by all HTML elements.

Syntax:

Parameter explanation:

expression: It specifies an expression to evaluate.

Let’s take an example to demonstrate ng-init directive.

See this example:

Test it Now

You may also like