I am trying to display a tree structure on UI. But getting an error.
Can't bind to 'target' since it isn't a known property of 'i'. ("v *ngFor="let item of files"> ]data-target="#{{item.reference}}" class="fa fa-caret-right" *ngIf="!(item.children.length==="): ng:///AppModule/SidenavComponent.html@9:34
Though this property exists in my json file as below:
[
{
"name": "great grandparent",
"reference": "great_grandparent",
"children": [
{
"name": "childless grandsibiling",
"reference": "childless_grandsibiling",
"children": []
},
{
"name": "grandparent",
"reference": "grandparent",
"children": [
{
"name": "childless sibiling",
"reference": "childless_sibling",
"children": []
},
{
"name": "another childless sibiling",
"reference": "another_childless_sibiling",
"children": []
},
{
"name": "parent",
"reference": "parent",
"children": [
{
"name": "child",
"reference": "child",
"children": []
},
{
"name": "another child",
"reference": "another_child",
"children": []
}
]
}
]
}
]
}
]
And my html file is as follows:
<div class="row">
<div class="col-md-12">
<div id="google_translate_element"></div>
</div>
</div>
<div class="container sidenav-tree">
<ng-template #recursiveList let-files>
<div *ngFor="let item of files">
<div class="row node-item">
<i data-toggle="collapse" data-target="#{{item.reference}}"
class="fa fa-caret-right" *ngIf="!(item.children.length===0)"></i>
{{item.name}}
</div>
<div id="{{item.reference}}" class="container collapse" *ngIf="!(item.children.length===0)">
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: item.children }"></ng-container>
</div>
</div>
</ng-template>
<ng-container *ngTemplateOutlet="recursiveList; context:{ $implicit: files }"></ng-container>
</div>
I am not able to figure out the cause for this failure. I have tried with all possible conditions I could apply to make it work. Please help me resolving this