AngularJS Tutorial - Bind data from scope








The following code shows how to Bind data from scope.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
</head><!-- ww w. ja v  a 2 s  . com-->
<body data-ng-app>
  <div data-ng-controller="AddressCtrl">
    <div>Name: {{name}}</div>
    <div>Street: {{address.street}}</div>
    <div>City: {{address.city}}</div>
</div>
<script type='text/javascript'>
function AddressCtrl($scope) {
   $scope.name = 'John Smith';
   $scope.address = {
      street : '9999 Main Blvd',
      city   : 'Los Angeles'
   };
}
</script>
</body>
</html>

The code above is rendered as follows: