AngularJS Tutorial - ng-bind








We can use ng-bind directive in place of the {{ }} template. The content is rendered as the child text node of the element on which ng-bind is declared.

Example

The following code shows how to ng-bind.


<!doctype html>
<html ng-app="myApp">
<head>
  <script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.0-rc.3/angular.js"></script>
</head><!--from   w  w  w  .java  2s  .c  o m-->
<body ng-init="greeting = 'Hello World'">

  <p ng-bind="greeting"></p>

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

</body>
</html>

The code above is rendered as follows: