【发布时间】:2017-09-21 03:45:18
【问题描述】:
有谁知道如何过滤掉 am angular 2 下拉列表中的报告结果。我目前正在尝试在模板 *ngFor 中执行此操作,但没有运气。我也会尝试定制管道。数据来自 JSON 数组。在下面的对象中,我试图只显示“国有实体”的一个实例
我的数据对象
items[
{
"currentBUName":"Financial Services"
}
{
"currentBUName":"State Owned Entities"
}
{
"currentBUName":"State Owned Entities"
}
]
我的ts代码提取
<ion-item>
<ion-label>Please select current business unit</ion-label>
<ion-select [(ngModel)]="selectedValue">
<ion-option *ngFor="let indexx of this.items;"[value]="indexx">{{indexx.currentBUName}}</ion-option>
</ion-select>
</ion-item>
【问题讨论】:
-
感谢您的回复,但感谢 Yoav Schniederman 来自此链接 stackoverflow.com/questions/41867448/…
transform(){ if(this.items!== undefined && this.items!== null){ console.log(_.uniqBy(this.items, 'currentBUName')); this.currentBUvals = _.uniqBy(this.items, 'currentBUName'); return _.uniqBy(this.items, 'currentBUName'); } return this.items; }
标签: arrays angular typescript ionic2 angularjs-filter