创建单独的列表项控制器:Plnkr上的演示
js
angular .module('testApp', []) .controller('testCtrl', function ($scope) { $scope.fooCollection = []; }) .controller('fooCtrl', function ($scope) { $scope.$watch('foo.bar', function (newValue, oldValue) { console.log('watch fired, new value: ' + newValue); }); });HTML
<html ng-app="testApp"> <body ng-controller="testCtrl"> <div ng-repeat="(fooKey, foo) in fooCollection" ng-controller="fooCtrl"> Tell me your name: <input ng-model="foo.bar" ng-change="doSomething()"> <br /> Hello, my name is {{ foo.bar }} </div> <button ng-click="fooCollection.push([])">Add a Namer</button> </body></html>


