[
{"_id":"5e56579e97dd2029e407f89d","name":"Loka","mobileno":25689,
"type":"D","gender":"Male","__v":0},
{"_id":"5e578a70547cff4058b26ee1","name":"NNN","mobileno":36954,
"type":"D","gender":"Male","__v":0},
{"_id":"5e57c02ece0c6928ac575798","name":"ssss","mobileno":855,
"type":"B","gender":"Male","__v":0},
{"_id":"5e57c33ece0c6928ac57579a","name":"ssss","mobileno":859,
"type":"B","gender":"Male","__v":0},
{"_id":"5e57c360ce0c6928ac57579b","name":"ssss","mobileno":5486,
"type":"B","gender":"Female","__v":0},
{"_id":"5e57c407ce0c6928ac57579c","name":"Dhaval","mobileno":24569,
"type":"C","gender":"Female","__v":0}
]
我想从对象数组上方获取每个值。我为上面的数组写了下面的代码
<div *ngFor="let items of customers">
{{items}}
</div>
我想要类似的输出
名称:Dhaval类型:C
答案 0 :(得分:3)
<div *ngFor="let items of customers">
{{items.name}} {{items.mobileno}} {{items.type}} {{item.gender}}
</div>
您可以使用相应的键遍历对象数组。
答案 1 :(得分:1)
如果要为数组中的每个项目输出一条消息,则可以使用插值。
<div *ngFor="let items of customers">
Name:{{items.name}} Type:{{items.type}}
</div>
答案 2 :(得分:1)
认为您正在寻找的是键值管道。
<div *ngFor="let items of customers">
<div *ngFor="let item of items | keyvalue">
{{item.key}}: {{item.value}}
</div>
</div>
答案 3 :(得分:1)