Lets say we have an AngularJS view whith a master detail relation. e.g. order and order details.
And we assume the details are rendered using an ng-repeat over order.details.
e.g.
<div ng-repeat="detail in orderCtl.order.details"
ng-controller="detailController as detailCtl">
I know that I can fetch the $scope.detail when the detailController is initialized.
/* initcontroller */
function($scope) {
console.log($scope.detail); //<-- this is the active item
}
But, that feels like a hack since I need to know in the controller what the ng-repeat variable name is, in this case detail
Is there any other way to get the active item from the repeater in the controller init?
If someone would change the ng-repeat variable name from detail to something else, then the controller would no longer work as expected.