AngularJS Bind Example

AngularJS Bind Example

AngularJS bind expression bind the variable with another place inside the DOM tree. Once you bind expression changes will be visible instantly. Below is example:

  • AngularJSBind.html:
<!DOCTYPE html>
<html data-ng-app="AngularJSBind">
<head>
<meta charset="ISO-8859-1">
<title>AngularJS Copy</title>
<style>
table, th, td {
    border: 1px solid black;
	width: 300px;
}
</style>
<script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.2.26/angular.min.js"></script>
<script>
  var app = angular.module('AngularJSBind', [])
    app.controller('BindController', ['$scope', function($scope) {
      $scope.name = 'Java Honk';
    }]);
</script>
</head>
<body data-ng-controller="BindController">
	<table>
	<tr>	
		<td><b>Enter your name:</b> <input type="text" ng-model="name"><br></td>
		</tr>
		<tr>
		<td><b>Your name is bind here:</b> <span ng-bind="name"></span></td>	
	</tr>
	</table>
</body>
</html>
  • Output:

2014-12-30 14_45_44-AngularJS Copy

  • Test this code in Plunker here
  • For more information please visit AngularJS API here

Leave a Reply

Your email address will not be published. Required fields are marked *