我试图弄清楚如何使用Angular和Pipes构建实时的产品过滤器。在我的html中,我有以下产品循环:
<div *ngFor="#product of products | filter">
<div class="product">{{product.id}}</div>
</div>
看来我可以通过输入filter:argument来向过滤器函数添加参数,我想知道如何才能添加一个包含来自页面输入字段的值的参数。我想根据是否要更改过滤器中的内容
<input type="checkbox">
是否检查。我怎么做?
使用本地模板变量:
<input #ref type="checkbox">
将值传递给过滤器:
<div *ngFor="#product of products | filter: ref.checked">
<div class="product">{{product.id}}</div>
</div>
本文收集自互联网,转载请注明来源。
如有侵权,请联系[email protected] 删除。
我来说两句