Hey there, I'm currently utilizing Angular recursive template to represent arrays recursively.
The code I've been following is provided in this link.
My array is dynamic in nature.
<ul>
<ng-template #recursiveList let-list>
<li *ngFor="let item of AlldepartmentList; let index = index">
<span (click)="getDepartment(item.id)"> {{item.department_name}} </span>
<ul *ngIf="item.children.length > 0">
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: item.children }"></ng-container>
</ul>
</li>
</ng-template>
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: list }"></ng-container>
</ul>
I'm passing the following object to the HTML view:
[{
"id": 3,
"department_name": "new",
"children": [{
"id": 4,
"department_name": "new",
"children": []
}, {
"id": 5,
"department_name": "new2",
"children": []
}, {
"id": 7,
"department_name": "new2123",
"children": []
}, {
"id": 8,
"department_name": "new21",
"children": []
}, {
"id": 11,
"department_name": "test",
"children": []
}]
},
{
"id": 6,
"department_name": "new2",
"children": []
}, {
"id": 2,
"department_name": "test",
"children": []
}]
Below are my dependency versions:
Angular CLI: 1.5.5
Node: 7.10.1
OS: linux x64
Angular: 5.2.2
animations, common, compiler, compiler-cli, core, forms
http, language-service, platform-browser
platform-browser-dynamic, router
@angular/cli: 1.5.5
@angular-devkit/build-optimizer: 0.0.42
@angular-devkit/core: 0.0.29
@angular-devkit/schematics: 0.0.52
@ngtools/json-schema: 1.1.0
@ngtools/webpack: 1.8.5
@schematics/angular: 0.1.17
typescript: 2.4.2
webpack: 3.8.1
I'm facing an error and most solutions seem to lack a strong logic base. Please correct me if I am mistaken or it's just a version compatibility issue.
VM42212 CostcentersComponent.ngfactory.js:573 ERROR RangeError: Maximum call stack size exceeded
at Object.debugUpdateDirectives [as updateDirectives] (VM41902 core.js:14852)
at checkAndUpdateView (VM41902 core.js:13999)
at callViewAction (VM41902 core.js:14350)
at execEmbeddedViewsAction (VM41902 core.js:14308)
at checkAndUpdateView (VM41902 core.js:14000)
at callViewAction (VM41902 core.js:14350)
at execEmbeddedViewsAction (VM41902 core.js:14308)
at checkAndUpdateView (VM41902 core.js:14000)
at callViewAction (VM41902 core.js:14350)
at execEmbeddedViewsAction (VM41902 core.js:14308)