Skip to content

Instantly share code, notes, and snippets.

@shilpasyal55
Last active July 7, 2019 15:34
Show Gist options
  • Save shilpasyal55/12c6d500e1d3d14c70ef5422b5478d58 to your computer and use it in GitHub Desktop.
Save shilpasyal55/12c6d500e1d3d14c70ef5422b5478d58 to your computer and use it in GitHub Desktop.
Filter functions of Autocomplete Component
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