在 *ngFor-- IONIC2/Angular2 中迭代两个数组 [英] Iterate two arrays in *ngFor-- IONIC2/Angular2
问题描述
我已将值存储在两个数组中以在单个 ion-list 中进行迭代.Billerstatusstate 和 Billerstatusnamelst 是两个数组.
I have stored values in two arrays to iterate in a single ion-list . Billerstatusstate and Billerstatusnamelst are the two arrays.
我已经尝试了以下迭代
<ion-list ion-item *ngFor="let stat of Billerstatusstate;let bil of Billerstatusnamelst " >
{{bil}} <button round>{{stat}}</button>
</ion-list>
和
<ion-list ion-item *ngFor="let stat of Billerstatusstate" *ngFor="let bil of Billerstatusnamelst " >
{{bil}} <button round>{{stat}}</button>
</ion-list>
它对两个局部变量都取第一个迭代值.
Its taking first iterated value for both local variable.
我有什么遗漏吗??
有没有其他方法可以将两个值存储在单个数组中,并使用 ngFor 将其拆分到 View 端..
is there anyother way to store both values in single array and split it in View side using ngFor..
推荐答案
我已经按照这个方法..我将值存储在单个数组而不是两个数组中,因为它来自单个源.
I have followed this approach.. I have stored values in single array instead of two arrays as it comes from a single source.
this.Billerstatusnamelst.push({name:"testname",Status:"Failure"});
在 HTML 部分
<ion-list ion-item *ngFor="let bil of Billerstatusnamelst " >
{{bil.name}} <button round>{{bil.Status}}</button>
</ion-list>
它对我有用..
这篇关于在 *ngFor-- IONIC2/Angular2 中迭代两个数组的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!