Having an issue with the ng-repeat directive. I have a parent controller containing an array of objects like this:
$scope.queue = [
{
name: 'Mark',
sex: 'Male',
age: 21
},
{...}
];
$scope.changePositionInQueue = function (currIndex, targetIndex) {
// move up / down person in queue
};
My goal is to pass the parent controller's function to my directive's isolated scope ('person'), while still being able to utilize '$index', '$first', and '$last' variables.
<person data-change-position="changePositionInQueue" data-person="person" ng-repeat="person in queue"></person>
Directive scope declaration:
scope: {
person: '=',
changePosition: '&'
}
The issue arises when creating an isolated scope within the ng-repeat loop as it causes the loss of ng-repeat properties. However, using a default scope set by ng-repeat provides access to the desired properties but limits the usage of the parent function.