Last active
July 7, 2019 15:34
-
-
Save shilpasyal55/12c6d500e1d3d14c70ef5422b5478d58 to your computer and use it in GitHub Desktop.
Filter functions of Autocomplete Component
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
getCars(name): Observable<any> { | |
//Here we perrform the simple call to filter function. You can also call to API here for the desired result. | |
return of(this.filterCars(name)) //used `of` to convert array to Observable | |
//return this.http.post("url", data, {headers}) //to get the result from API use this line | |
} | |
filterCars(name) { | |
return this.cars.filter((val) => val.toLowerCase().includes(name.toLowerCase()) == true ) | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment