Answer the question
In order to leave comments, you need to log in
Angular-recursion how to add nesting count count?
There is a service that outputs nested directives: https://github.com/marklagendijk/angular-recursion
How to modify the service itself or a directive based on it in order to get a nesting counter?
Answer the question
In order to leave comments, you need to log in
the easiest way to pass the nesting level as an attribute. more or less like this:
angular.module('myModule', ['RecursionHelper']).directive("tree", function(RecursionHelper) {
return {
restrict: "E",
scope: {family: '=', level='@'},
template:
'<p>{{ family.name }}{{test }}</p>'+
'<ul>' +
'<li ng-repeat="child in family.children">' +
'<tree family="child" level="{{(level)?level + 1: 1}}"></tree>' +
'</li>' +
'</ul>',
compile: function(element) {
return RecursionHelper.compile(element, function(scope, iElement, iAttrs, controller, transcludeFn){
});
}
};
});
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question