I've been working on a custom pipe following the instructions carefully, but I keep encountering an error when trying to filter my list.
Below is the code for my custom pipe:
import { Pipe, PipeTransform } from '@angular/core';
import { Icandidat } from './candidat/icandidat';
@Pipe({
name :'personFilter'
})
export class PipeFilter implements PipeTransform{
transform(value: Icandidat[], filterBy : string) : Icandidat[] {
filterBy = filterBy ? filterBy.toLocaleLowerCase() : null;
return filterBy? value.filter((person : Icandidat) =>
person.candidatNom.toLocaleLowerCase().indexOf(filterBy) !== -1) : value;
}
}
This is the interface used:
export interface Icandidat {
prog1 : string ;
progName1 : string ;
progEl1 : string ;
candInfo : any [];
filterBy : string ;
candidatID : number;
candidatNom : string;
canditatPrenom : string ;
candidatParti : string;
candidatDepartement : string;
candidatCommune : string ;
candidats : Icandidat;
errorMessage : string;
}
The component associated with this setup:
import { PaeServiceService } from '../pae-service.service';
import { Icandidat } from './icandidat';
import { NgModel } from '@angular/forms/src/directives';
import { Component, OnInit } from '@angular/core';
// Component and initialization details here...
Lastly, here is a snippet of the template:
<!-- Template code here -->
Can anyone pinpoint what might be causing the issue in this scenario?