【发布时间】:2021-02-26 00:13:33
【问题描述】:
我的json数据是
{
"status": "Sucess",
"data": {
"id": 3,
"permissions": {
"logentry": [
{
"id": 2,
"name": "Can change log entry",
"status": 0
},
{
"id": 3,
"name": "Can delete log entry",
"status": 0
},
{
"id": 4,
"name": "Can view log entry",
"status": 0
}
],
"company": [
{
"id": 29,
"name": "Can add company",
"status": 0
},
{
"id": 30,
"name": "Can change company",
"status": 0
},
{
"id": 31,
"name": "Can delete company",
"status": 0
},
{
"id": 32,
"name": "Can view company",
"status": 0
}
],
"contenttype": [
{
"id": 17,
"name": "Can add content type",
"status": 0
},
{
"id": 18,
"name": "Can change content type",
"status": 0
},
{
"id": 19,
"name": "Can delete content type",
"status": 0
},
{
"id": 20,
"name": "Can view content type",
"status": 0
}
],
"moduletype": [
{
"id": 25,
"name": "Can add module type",
"status": 0
},
{
"id": 26,
"name": "Can change module type",
"status": 0
},
{
"id": 27,
"name": "Can delete module type",
"status": 0
},
{
"id": 28,
"name": "Can view module type",
"status": 0
}
]
},
"name": "manager"
},
"message": "Successful Response data"
}
我需要使用 Angular 8 解析数据并获取组件中的权限内容 这里lognetry、comapany、contenttype、moduletype等权限键都是动态生成的。
我是 Angular 新手,我尝试过这种方式来获取详细信息 通过服务接收json数据并在data
中分配<div *ngFor="let item of data">
<div *ngFor="let temp of item.permissions |keyvalue">
<div *ngFor="let temp1 of temp|keyvalue ">
Key: <b>{{temp1.key}}</b> and Value: <b>{{temp1.value}}</b>
</div>
</div>
</div>
我需要在我的组件中以这种方式打印所有数据的解决方案 谁能帮帮我
【问题讨论】:
标签: json parsing dynamic angular8