I'm struggling to get my head around how to filter an array of objects based on another array of objects using the angular pipe. What i have so far is a pipe that filters based on a single argument.
I have 2 arrays, array1 and array 2, which both contain complex objects. The filtered array (array1) should only contain objects where array1.value === array2.value
My code so far:
import { Injectable, Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'arrayFilter'
})
@Injectable()
export class AttributeFilterPipe implements PipeTransform {
transform(array: any[], filterFrom: any[]): any {
return array.filter(item => item.value.indexOf(filterFrom[0].value) !== -1);
}
}