我已将值存储在两个数组中,以便在单个离子列表中进行迭代. Billerstatusstate和Billerstatusnamelst是两个阵列.
我尝试了以下迭代
<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>
它取两个局部变量的第一个迭代值.
我错过了什么?
有没有其他方法可以将两个值存储在单个数组中,并使用ngFor在View端拆分它.
我可以创建一个管道来将你的两个数组“合并”为一个数组,然后你可以迭代这个新的数组.
这是一个示例:
@Pipe({ name: 'merge' }) export class MergePipe { transform(arr1,arr2) { var arr = []; arr1.forEach((elt,i) => { arr.push({ state: elt,name: arr2[i] }); }); } }
并以这种方式使用它:
<ion-list ion-item *ngFor="let elt of Billerstatusstate | merge:Billerstatusnamelst" > {{elt.name}} <button round>{{elt.state}}</button> </ion-list>
原文地址:https://www.jb51.cc/angularjs/143684.html
版权声明:本文内容由互联网用户自发贡献,该文观点与技术仅代表作者本人。本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌侵权/违法违规的内容, 请发送邮件至 dio@foxmail.com 举报,一经查实,本站将立刻删除。