I need an angular example of one controller wrapping the other one.
As an example, I want to split some logic between EndpointListController and EndpointController.
EndpointListController will have the means of getting the data from storage, plus some functions applicable on the entire list, EndpointController however, will have the logic for one individual endpoint.
It would be really nice to loop through them with ng-repeat and call the methods directly on the endpoint, like this:
<table ng-controller="EndpointListController">
<tr ng-repeat="endpoint in endpoints">
<td><input type="checkbox" ng-click="endpoint.select()"></td>
<td>{{endpoint.label}}</td>
<td><span class="label label-info">2014-10-10 23:59</span></td>
<td><span class="label label-success">success</span></td>
<td><a href="" class="glyphicon glyphicon-cloud"></a></td>
</tr>
</table>
currently I'm forced to do something like this:
<tr ng-repeat="endpoint in endpoints" ng-controller="EndpointController" endpoint-data="{{endpoint}}">
Not very elegant ...
Is the thing I'm trying to accomplish even possible with angular? Probably I'm looking at this wrong, if someone can point me in the right direction, it would be greatly appreciated.
ng-repeatalready creates a child scope<table end-point-list>and your controller should belong to that directive. Then you have a child directive for each endpoint<tr end-point>.