使用Angular在索引中的循环索引
我有一个看起来像这样的阵列;
[
0.{name: name, prod: [0{...}, 1{...}]},
1.{name: name, prod: [0{...}, 1{...}]},
2.{name: name, prod: [0{...}, 1{...}]},
3.{name: name, prod: [0{...}, 1{...}]},
]
因此,现在我使用索引进行ngfor循环:
*ngfor =“让prodlist的p; in i”
index
这显然给了我第一个索引:[0,1,2,3],但是我想为第二个数组索引。
我尝试了:
*ngfor =“让prodlist.prod; index as i”
但似乎不起作用。
我的html:
<ion-col size="6" *ngFor="let p of prodList; index as i">
<h1>{{p.name}}</h1>
<p>{{p.prod[i].description}}</p>
<p>{{p.prod[i].price}}</p>
I have a array that looks like this;
[
0.{name: name, prod: [0{...}, 1{...}]},
1.{name: name, prod: [0{...}, 1{...}]},
2.{name: name, prod: [0{...}, 1{...}]},
3.{name: name, prod: [0{...}, 1{...}]},
]
So now I do a ngfor loop using the index:
*ngFor="let p of prodList; index as i"
This obviously gives me the first index: [0,1,2,3], however I would like to index the second array.
I have tried:
*ngFor="let p of prodList.prod; index as i"
But does not seem to be working.
my html:
<ion-col size="6" *ngFor="let p of prodList; index as i">
<h1>{{p.name}}</h1>
<p>{{p.prod[i].description}}</p>
<p>{{p.prod[i].price}}</p>
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论