Javatpoint Logo
Javatpoint Logo

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



Help Others, Please Share

facebook twitter pinterest

Learn Latest Tutorials


Preparation


Trending Technologies


B.Tech / MCA