FarmMapsLib/projects/common/src/fm/services/typeahead.service.ts

30 lines
1.2 KiB
TypeScript
Raw Normal View History

2019-07-15 14:54:19 +00:00
import { Injectable } from '@angular/core';
import { Observable , Observer } from 'rxjs';
import { ITypeaheadItem } from '../models/typeahead.item';
import { HttpClient, HttpParams } from "@angular/common/http";
import { AppConfig } from "../shared/app.config";
2019-11-05 16:19:33 +00:00
@Injectable({
providedIn: 'root',
})
2019-07-15 14:54:19 +00:00
export class TypeaheadService {
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
2019-07-18 16:59:42 +00:00
}
ApiEndpoint() {
return this.appConfig.getConfig("apiEndPoint");
2019-07-15 14:54:19 +00:00
}
2023-03-06 13:04:14 +00:00
getSearchTypeaheadItems(searchText:string,skip = 0,take = 10): Observable<ITypeaheadItem[]> {
2019-07-18 16:59:42 +00:00
return this.httpClient.get<ITypeaheadItem[]>(`${this.ApiEndpoint()}/api/v1/typeahead/search/?q=${searchText}&skip=${skip}&take=${take}`);
2019-07-15 14:54:19 +00:00
}
2023-03-06 13:04:14 +00:00
getTagTypeaheadItems(searchText: string, skip = 0, take = 10): Observable<ITypeaheadItem[]> {
2019-07-18 16:59:42 +00:00
return this.httpClient.get<ITypeaheadItem[]>(`${this.ApiEndpoint()}/api/v1/typeahead/tag/?q=${searchText}&skip=${skip}&take=${take}`);
2019-07-15 14:54:19 +00:00
}
2023-03-06 13:04:14 +00:00
getCityTypeaheadItems(searchText: string, skip = 0, take = 10): Observable<ITypeaheadItem[]> {
return this.httpClient.get<ITypeaheadItem[]>(`${this.ApiEndpoint()}/api/v1/typeahead/city/?q=${searchText}&skip=${skip}&take=${take}`);
}
2019-07-15 14:54:19 +00:00
}