AngularJS watch object

http://stackoverflow.com/questions/11592538/nested-models-in-angularjs Resources: https://groups.google.com/d/topic/angular/VD77QR1J6uQ/discussion https://groups.google.com/d/topic/angular/-Tx8U9Xm07k/discussion

by remguif

HTML

<div ng-app="watchApp" ng-controller="watchCtrl">
      <div ng-repeat="a in b">
        <input type="text" ng-model="a.value" />{{a.value}}
      </div>
        {{count}}-{{b}}
    </div>

JavaScript

angular.module('watchApp', []).controller('watchCtrl', function($scope) {
    $scope.count = 0;
    $scope.b = [{value: 1},
    {value: 2},
    {value: 3},
    {value: 4},
    {value: 5},
    {value: 6}];

    $scope.$watch('b', function() {
        // do something here
        $scope.count += 1;
    }, true);
});