简体   繁体   English

如何使用 Angular 6 从 JSON 数据实现树视图

[英]How to achieve tree view from JSON data using Angular 6

I want to design a checkbox tree structure using following data coming from Web API using Angular 6. How can I achieve it please help.我想使用来自使用 Angular 6 的 Web API 的以下数据设计复选框树结构。我该如何实现它,请帮助。

[
{
    "id": 1,
    "parent_id": 0,
    "Fund_type":"A&P"   
},
{
    "id": 2,
    "parent_id": 1,
    "Fund_type": "On Invoice"
},
{
    "id": 3,
    "parent_id": 2,
    "Fund_type": "Banded packs-Consumer"
},
{
    "id": 4, 
    "parent_id": 2, 
    "Fund_type": "Banded packs-Shopper" 
},....]

Where id=1 is the root node and id=2 is the direct child of it and id=3 &4 are direct children of id=2(You can understand the structure from parent_id )其中 id=1 是根节点, id=2 是它的直接子节点, id=3 &4 是 id=2 的直接子节点(你可以从 parent_id 理解结构)

Thanks.谢谢。

您需要按照下面给出的示例更改数据并使用此组件: https : //www.npmjs.com/package/ngx-treeview

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM