选择类别:
<ion-select name="categories">
<ion-option *ngFor="let category of categories;">
{{category}}
</ion-option>
</ion-select>
列出项目:
<ion-item-sliding *ngFor="let item of items; let idx = index;">
<ion-item>
<h2>{{item.title}}</h2>
</ion-item>
...
</ion-item-sliding>
如何使用(选择)中的值来选择列出哪个类别?我尝试添加一个 ngModule 并将其作为条件传递到滑动 ngFor 中,但它不起作用。
最佳答案
您可以使用ngx-pipes用于在数组和字符串中进行令人难以置信的过滤和转换的库。
对于您的问题,您可以使用ngx-pipes
库中的filterBy管道。
<ion-option *ngFor="let category of categories | filterBy:['name']:selectedVariable;">
关于angular - 如何根据选定的下拉值过滤 *ngFor 结果,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/45267001/