I am in need of an angular example where one controller wraps another. For instance, I am looking to divide some logic between EndpointListController
and EndpointController
.
EndpointListController
will handle retrieving data from storage, along with functions applicable to the entire list, whereas EndpointController
will focus on individual endpoints.
It would be great to iterate through them using ng-repeat and directly call methods on each endpoint, like so:
<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 am having to do something like this:
<tr ng-repeat="endpoint in endpoints" ng-controller="EndpointController" endpoint-data="{{endpoint}}">
This approach feels a bit cumbersome...
Is it actually feasible to achieve what I'm aiming for with angular? Perhaps I'm approaching this incorrectly, any guidance in the right direction would be highly appreciated.