我正在尝试根据类别和大小进行路由,路由 url 更改,但仅基于第二个过滤器路由。)侧过滤器单击第一个过滤器,即。)按类别更改 url 但不路由
app.component.ts
private populateProduct(){
this.productService
.getAll()
.switchMap(products => {
this.products = products;
return this.route.queryParamMap;
})
.subscribe(params => {
this.category = params.get('category')
this.applyFilter()
this.size = params.get('size')
this.sizeFilter(); ====> Only thse size filter works
})
}
private applyFilter() {
this.filteredProducts = (this.category) ?
this.products.filter(p => p.category === this.category) :
this.products;
}
private sizeFilter(){
this.filteredProducts = (this.size) ?
this.products.filter(p => p.size === this.size) :
this.products;
}