我使用纯管道来过滤数据,我知道不推荐这样做,但在我的情况下,过滤只会在url更改时发生,大多数情况下是在页面加载时。这是烟斗
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'sortPipe'
})
export class SortPipePipe implements PipeTransform {
listArr = []
transform(value: any[], args?: string): any[] {
value.forEach((val, index) => {
if (val.group.indexOf(args) > -1) {
console.log(val); // this retuning object and not array
listArr.push(val); // not allowed
}
});
retune val ; //this is object not array
});
return null;
}
}
https://stackoverflow.com/questions/52140664
复制相似问题