I have a repeated directive which inherits the scope from it's parent controller.
<div ng-controller="myController">
{{ message }}
<person ng-repeat="person in persons"></person>
</div>
app.controller('myController', function ($scope) {
$scope.message = "A";
$scope.persons = { 1: {}, 2: {}, 3: {} }
});
But when I change the scope inside the directive, the parent scope does not update.
app.controller('PersonController', function ($scope) {
$scope.message = "B";
});
app.directive("person", function () {
return {
restrict: 'E',
transclude: true,
controller: 'PersonController',
template: '{{ message }}'
};
});
http://jsfiddle.net/hientc/L8xo9338/1/
This only happens when I have an ng-repeat on the directive. If I remove the ng-repeat, the parent scope is updated when the directive scope is updated.
How do I make two-way binding work for ng-repeat?