【发布时间】:2020-11-16 08:46:25
【问题描述】:
在这个 mat-option 中,我试图显示来自我订阅的 observable 的数据。
<mat-option *ngFor="let option of (filteredCustomer | async)?.Items"
[value]="option" (onSelectionChange)="searchDest($event)">
{{option.Cityname}}
</mat-option>
observable的名字是filteredCustomer。
现在在 mat 选项中,我尝试显示城市名称。结果就是这样。
Los Angeles
Boston
Detroit
Los Angeles
Washington
Los Angeles
如你所见,我有重复。
是否可以删除重复项(如 sql 中的 distinct)?
我的 observable 来自这个 ts 文件:
public filterCity() {
var parameters = new CitySearchParameters(100, 0);
parameters.City = this.city;
this.filteredCustomer = this.customerService.get(parameters);
if (typeof (this.city) == "object") {
var curCity: any = this.city;
this.city = curCity.City;
}
}
谢谢
【问题讨论】:
-
预期输出是什么?只是一个字符串列表?
标签: angular duplicates observable distinct