I have created a Custom Pipe for my Drop Down But the filtered values dosent seem to get passed to the component there is also no error in the console .
My Component - template
<select [(ngModel)]="userid" (ngModelChange)="onChange()">
<option value=""> </option>
<option *ngFor = "let user of (users|startswith)" [value] = "user.id">
{{user.first_name}}
</option>
</select>
ngOnInit():void{
this.appService.getUsers().then(user =>this.users = user);
}
The users array is populated from a web service
My Custom Pipe
import { Pipe,PipeTransform } from '@angular/core'
import { Users } from './users'
@Pipe({
name :'startswith',
})
export class PipeFilter implements PipeTransform{
transform(value : any[]){
if(value == null){
return null;
}else{
return value.filter(item => {
console.log(item.first_name.includes('e'));
item.first_name.includes('e')}
);
}
}
}
You are missing one
return
statement: