Private archive copy · Unofficial site · Content copyright belongs to Runoob Tutorial and the original authors · View Original

AngularJS ng-init Directive

AngularJS ng-init Instruction

AngularJS Reference Manual AngularJS Reference Manual


AngularJS Examples

Create a variable when initializing the application:

<

div

ng-app=

""

ng-init=

"myText='Hello World!'"

<

h1

{{myText}}

<

/h1

Try it »


Definition and Usage

ng-init The directive executes the given expression.

ng-init The directive adds unnecessary logic to the scope. It is recommended that you ** ng-controller** directive to execute it instead.


Syntax

<

element

ng-init=

"expression"

<

/element

All HTML elements support this directive.


Parameter value

Value Description
expression The expression to execute.

AngularJS Reference Manual AngularJS Reference Manual