Good evening,
Is there any way to create a template that recursively shows a structure and has an onclick function on every item. This onclick function needs the current index including all parent indexes of this element (for example [0][2][1] for BMW in the list below).
A [0]
  Tree [0][0]
    ...
  House [0][1]
    ...
  Car [0][2]
    Mercedes [0][2][0]
    BMW [0][2][1]
    Audi [0][2][2]
    VW [0][2][3]
    Chrysler [0][2][4]
B [1]
  ...
C [2]
  ...
My current directives look like this but I have no idea how I cant get the FULL INDEX of every element for the ng-click function.
app.directive('collection', function () {
    return {
        restrict: "E",
        replace: true,
        scope: {
            collection: '='
        },
        template: `
          <ul>
            <member ng-repeat='member in collection'
                    member='member' index='$parent.index + $index'>
            </member>
          </ul>`
    }
});
app.directive('member', function ($compile) {
    return {
        restrict: "E",
        replace: true,
        template: "<li ng-click=\"select(member)\">{{member.title}}</li>",
        link: function (scope, element, attrs) {
            var collectionSt = '<collection collection="member.sub"></collection>';
            if (angular.isArray(scope.member.sub)) {
                $compile(collectionSt)(scope, function(cloned, scope) {
                    element.append(cloned); 
                  });
            }
        }
    }
});
 
    