Bind input to object properties in scope

Description

The following code shows how to Bind input to object properties in scope.

Example


<!DOCTYPE html>
<html  ng-app>
<head>
<script src="https://ajax.googleapis.com/ajax/libs/angularjs/1.2.13/angular.js"></script>
<!--from  w  w  w .j a  v a2s. c  o  m-->
<script type='text/javascript'>

var myctrl = function($scope) {
    $scope.items = [{value: 1},{value: 2},{value: 3}];
    $scope.itemEdit1 = $scope.items;
    $scope.itemEdit2 = $scope.items;
};
</script>
</head>
<body>
  <html ng-app>
<body ng-controller="myctrl">
    <div ng-repeat="item in itemEdit1">
        <input ng-model="item.value" type="text"/>
    </div>
    Edit 1: {{itemEdit1}}<br/>
    <div ng-repeat="item in itemEdit2">
        <input ng-model="item.value" type="text"/>
    </div>
    Edit 2: {{itemEdit2}}
</body>
</html>
</body>
</html>

Click to view the demo





















Home »
  AngularJS »
    AngularJS Example »




Controller
Directives
Expression
Filter
Form
Inject
Scope
Server
Style
Template
Utilities