react-code-dataset / react-query /examples /angular /rxjs /src /app /services /autocomplete-service.ts
Download react-query/examples/angular/rxjs/src/app/services/autocomplete-service.ts from Devendra174/react-code-dataset: direct link, hf CLI and curl.
- Browser
- Download file 501 Bytes
-
https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/angular/rxjs/src/app/services/autocomplete-service.ts
- Command line
-
hf download hf://datasets/Devendra174/react-code-dataset@1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/angular/rxjs/src/app/services/autocomplete-service.ts
-
curl -L -o autocomplete-service.ts https://huggingface.co/datasets/Devendra174/react-code-dataset/resolve/1e92f2d0b9e054abc23a53595fd89ad3e2b4a34e/react-query/examples/angular/rxjs/src/app/services/autocomplete-service.ts
501 Bytes
| import { HttpClient } from '@angular/common/http' | |
| import { Injectable, inject } from '@angular/core' | |
| import { of } from 'rxjs' | |
| interface Response { | |
| suggestions: Array<string> | |
| } | |
| ({ | |
| providedIn: 'root', | |
| }) | |
| export class AutocompleteService { | |
| readonly #http = inject(HttpClient) | |
| getSuggestions = (term: string = '') => | |
| term.trim() === '' | |
| ? of({ suggestions: [] }) | |
| : this.#http.get<Response>( | |
| `/api/autocomplete?term=${encodeURIComponent(term)}`, | |
| ) | |
| } | |