I'm using the controller as syntax, which works great for sharing between
controller directives, but I can't figure out how to do this with
ng-repeat. It seems to insist that the data is a scope variable (not this)
which is not what I want.
<div ng-controller="StudyCtrl as study">
{{study.name}}
<input type="text" ng-model="data[0].name">
<ul>
<li ng-repeat="item in data">{{item.name}}</li>
</ul>
<div ng-controller="OtherCtrl as other">
{{study.name}} <!-- I can access this! -->
<input type="text" ng-model="study.name"> <!-- I can even change
on both ctrls -->
<input type="text" ng-model="data[0].name"> <!-- this will update
in both ctr inputs, but not on the ng-repeat! -->
</div>
// in my controller I would have
this.name = "myname";
// using $scope.data = {} works, but then I don't have full access to it
The point of this is, I have an ng-repeat with one controller and scope and
a form that allows the user to edit this data with another controller and
scope- When there is a change, it needs to be reflected in both spots and
I'm trying to avoid root scope or passing objects back and forth in
services.
Thanks for the help!
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at http://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.