FarmMapsLib/projects/common/src/fm/services/codelistitem.service.ts
Peter Bastiani 63ffdf2519
All checks were successful
FarmMaps.Develop/FarmMapsLib/develop This commit looks good
AW-803 Pass array (take 2).
2020-01-22 14:18:09 +01:00

28 lines
946 B
TypeScript

import { Injectable } from '@angular/core';
import { Observable } from 'rxjs';
import { HttpClient, HttpParams } from "@angular/common/http";
import { AppConfig } from "../shared/app.config";
import { ICodeListItem } from '../models/code.list.item';
@Injectable({
providedIn: 'root',
})
export class CodeListItemService {
constructor(public httpClient: HttpClient, public appConfig: AppConfig) {
}
ApiEndpoint() {
return this.appConfig.getConfig("apiEndPoint");
}
getCodeListItems(codelist: string[], codegroup?: string, dataFilter?: any): Observable<ICodeListItem[]> {
var params = new HttpParams();
for (const cl of codelist) {
params = params.append('cl', cl);
}
if (codegroup) params = params.append("g", codegroup);
if (dataFilter) params = params.append("df", dataFilter);
return this.httpClient.get<ICodeListItem[]>(`${this.ApiEndpoint()}/api/v1/codelistitems/`, { params: params });
}
}