我有一个JSON数据,它由ID和parentID组成,
现在我需要用ID和它的parentID绑定HTML中的值。
JSON数据:
(19) [{â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}, {â¦}]
0: {ID: 1, Text: "Home / Dashboard", Description: "Home / Dashboard", ParentMenuId: 0, isChecked: true}
1: {ID: 2, Text: "User Management", Description: "User Management", ParentMenuId: 0}
2: {ID: 3, Text: "Basic Users", Description: "Basic Users", ParentMenuId: 2}
3: {ID: 4, Text: "Admin Users", Description: "Admin Users", ParentMenuId: 2}
4: {ID: 5, Text: "Dicom", Description: "Dicom", ParentMenuId: 0}
5: {ID: 6, Text: "EMR", Description: "EMR", ParentMenuId: 0}
6: {ID: 7, Text: "Case Management", Description: "Case Management", ParentMenuId: 0}
7: {ID: 8, Text: "System Settings", Description: "System Settings", ParentMenuId: 0}
8: {ID: 9, Text: "Deployment", Description: "Deployment", ParentMenuId: 0}
9: {ID: 10, Text: "Environment", Description: "Environment", ParentMenuId: 0}
10: {ID: 12, Text: "Lookup Master", Description: "Lookup Master", ParentMenuId: 8}
11: {ID: 13, Text: "User Authorization", Description: "User Authorization", ParentMenuId: 8}
12: {ID: 14, Text: "Report", Description: "Report", ParentMenuId: 0, isChecked: true}
13: {ID: 15, Text: "Admin Authorization", Description: "Admin Authorization", ParentMenuId: 8}
14: {ID: 16, Text: "Multilingual Master", Description: "Multilingual Master", ParentMenuId: 8}
15: {ID: 17, Text: "Cache Server", Description: "Cache Server", ParentMenuId: 10, isChecked: true}
16: {ID: 18, Text: "Cache Details", Description: "Cache Details", ParentMenuId: 10, isChecked: true}
17: {ID: 19, Text: "Data Storage", Description: "Data Storage", ParentMenuId: 10}
18: {ID: 20, Text: "Viewers", Description: "Viewers", ParentMenuId: 10}
length: 19
: Array(0)
TS:
getMenu() {
this._Service.getMenu()
.subscribe(res => {
this.userMenu = res.Body.Data
})
}
HTML:
<div>
<div id="accordion" class="panel-group">
<ul class="metismenu" id="menu">
<li class="m--5" *ngFor="let menu of userMenu">
<a class="nav-link">
<input type="checkbox" [checked]="menu.isChecked" (click)="selectedMenu($event.target.checked, menu.ID)">
<span class="nav-text p-l10">{{menu.Text}}</span>
</a>
</li>
</ul>
</div>
</div>
-
所以,这里我希望父对象在顶部,子对象必须在父对象的正下方,并有一个制表符空间。
-
选中子项时,也应自动选中父项。
我的要求是:
但我是这样做的:
Demo Link