【发布时间】:2019-09-12 19:03:04
【问题描述】:
我正在尝试获取对象子值但不工作。我不知道我的代码哪里出错了。任何人都可以找到解决方案吗?我正在尝试显示来自对象的 li 值。
test.json:
"main":[{
"power":"coming",
"cell":"2min",
"li":[
{
"text":"Lorem ipsom"
},
{
"text":"Ipsom klgtoy"
},
{
"text":"Klopi"
},
{
"text":"Mkhoi ipsom"
}
]
}];
app.component.html
<div *ngFor="val of main let i=index">
<ul>
<li>{{ val.li.text }}</li>
</ul>
</div>
【问题讨论】:
-
将
"power":"coming:,更改为"power":"coming" -
@IanPreglo:抱歉..已编辑但无法正常工作
-
你还有这个
"power":"coming":,...确保它是这个"power":"coming",
标签: typescript angular6 angular5 angular7