Есть класс с пользователями и pipe который ищет в нем элементы, но один из объектов класса стал массивом и поиск сломался помогите починить.
Поиск:
import { Pipe, PipeTransform } from '@angular/core';
@Pipe({
name: 'FilterPipe',
})
export class FilterPipe implements PipeTransform {
transform(value: any, input: string) {
if (input) {
input = input.toLowerCase();
return value.filter(function (el: any) {
if (el.phone.toLowerCase().indexOf(input) > -1) {
return el.phone.toLowerCase().indexOf(input) > -1;
}
if (el.mobile.toLowerCase().indexOf(input) > -1) {
return el.mobile.toLowerCase().indexOf(input) > -1;
}
if (el.dep.toLowerCase().indexOf(input) > -1) {
return el.dep.toLowerCase().indexOf(input) > -1;
}
if (el.email.toLowerCase().indexOf(input) > -1) {
return el.email.toLowerCase().indexOf(input) > -1;
}
if (el.owner.toLowerCase().indexOf(input) > -1) {
return el.owner.toLowerCase().indexOf(input) > -1;
}
})
}
return value;
}
}
Класс в котором ищем:
export class Member {
id: number;
phone: string;
mobile: string[];
dep: string;
email: string;
owner: string;
}
Когда mobile: string - был не массивом все работало, но нужно иметь несколько номеров и поиск отказывается так искать.