【发布时间】:2019-08-13 08:11:51
【问题描述】:
使用 ngFor 从 Object 中获取子对象,
我想显示属性对象的子对象。 喜欢 : first_name, last_name, address , inside address 我们有 street_1, street_2 等,使用 ngFor
HTML:
<div *ngIf="!!JsonSchema">
<div *ngFor="let field of JsonSchema.properties"> {{field | json}}</div>
</div>
TS:
JsonSchema = {
"type": "object",
"properties": {
"first_name": {
"type": "string"
},
"last_name": {
"type": "string"
},
"address": {
"type": "object",
"properties": {
"street_1": {
"type": "string"
},
"street_2": {
"type": "string"
},
"city": {
"type": "string"
},
"state": {
"type": "string",
},
"zip_code": {
"type": "string"
}
}
},
}
【问题讨论】: