English | 简体中文 | 繁體中文 | Русский язык | Français | Español | Português | Deutsch | 日本語 | 한국어 | Italiano | بالعربية

AngularJS ng-init Instruction

AngularJS Reference Manual

<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<script src="https://cdn.staticfile.org/angular.js/1.4.6/angular.min.js"></script>
</head>
<body>
<div ng-app="" ng-init="myText='Hello World!'">
<h1>{{myText}}</h1>
<p> ng-The init directive creates an AngularJS variable, which you can use in your application.</p>
</div>
</body>
</html>
Test see ‹/›

Definition and Usage

ng-init The directive executes the given expression.

ng-init The directive adds some unnecessary logic to the scope, it is recommended that you can do it in the controller ng-controller The directive executes it.

Syntax

   <element ng-init="expression" ></element>

All HTML elements support this directive.

Parameter value

ValueDescription
expressionExecuted expressions.

AngularJS Reference Manual