ng-init

Description

ng-init set ups state inside the scope.

Example

The following code shows how to ng-init.


<!doctype html>
<html ng-app="myApp">
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.2/angular.js"></script>
</head><!--   w w  w .j a v a  2  s  .co m-->
<body>

  <div ng-init="greeting='Hi'; person='AngularJS'">
    {{greeting}} {{person}}
  </div>

  <script>
    angular.module('myApp', []);
  </script>

</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Tutorial »




Introduction
Buildin Filters
Buildin Directives