在* ngFor-- IONIC2 / Angular2中迭代两个数组 [英] Iterate two arrays in *ngFor-- IONIC2/Angular2

查看:161
本文介绍了在* ngFor-- IONIC2 / Angular2中迭代两个数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我已将值存储在两个数组中,以便在单个离子列表中进行迭代。 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屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆