Bind data from scope

Description

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><!--  w w w . j a  v a 2  s .co m-->
<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>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities