AngularJs ng-bind Example

What is an ng-bind directive?

The “ng-bind” as the name suggest is used to bind/replace text content of any particular HTML element with the value of given expression that is used against the ng-bind. The value of the specified HTML element will be updated whenever the value of given expression will be changes.

Example,

<!DOCTYPE html>
<html lang="en">

<head>
  <title>Angular Demo</title>
  <script data-require="[email protected]" src="https://code.angularjs.org/1.5.8/angular.js" data-semver="1.5.8"></script>
  <script>
    var myApp = angular.module("AngularApp", []);
    myApp.controller("HelloController", function($scope) {
      $scope.text = "enter text here...";
    });
  </script>
</head>

<body ng-app="AngularApp">
  <div ng-controller="HelloController">
    Enter anything you want to display:
    <input type="text" ng-model="text">You Entered : <span ng-bind="text"></span>
  </div>
</body>

</html>

The Live demo,

About Blogger

ANIL SINGH

Hey! I am Anil Singh. I am Active Blogger, Writer and Programmer. I love learning new technologies, programming, blogging and participating the forum discussions more...
http://www.code-sample.com
http://www.code-sample.xyz

    Blogger Comment
    Facebook Comment

0 comments:

Post a Comment

SQL Server NodeJs TypeScript JavaScript Angular SQL Server My Book