Reputation: 9617
See https://plnkr.co/edit/7K03F7Orscz0PZdeanNK
export class Filter implements PipeTransform {
public transform(value: any, args: any[] = []): any {
return value.filter(() => true);
// return value;
}
}
I'm trying to write a pipe that filters an array. The problem is when I filter the array, the filter function returns a new array and then I get an Expression X changed after it's checked error. I don't get this error only if I mutate the array in place, but this is not what I want to do. Is there anyway of transforming input values using a pipe and not get this error?
Upvotes: 2
Views: 112
Reputation: 657118
Cache the result and return the cached result while the passed array or filter arguments didn't change.
Upvotes: 1