I am working on some project and i can't find the right answer for my search pipe. This is my code:
import {Pipe} from '@angular/core';
@Pipe({
name: 'SearchPipe'
})
export class SearchPipe {
transform (value, [queryString]) {
if (value==null) {
return null;
}
if (value=="") {
return null;
}
if(queryString !== undefined){
return value.filter(item=>item.model.toLowerCase().indexOf(queryString.toLowerCase()) !== -1) ;
}else{
return value;
}
}
}
And i get all search result that contain letter A when i enter that in search. I need to search my json with word not with letter. Sorry for my bad language, i hope you will understand it. This is the JSON.
[
{
"brand": "Suzuki",
"condition": "polovno",
"salesman": "Automotive",
"model": "Vitara"
}
]
If someone can modify code i would be very happy. Thanks in advance!