23 lines
663 B
TypeScript
23 lines
663 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import {BehaviorSubject} from 'rxjs';
|
|
import {HttpClient} from '@angular/common/http';
|
|
import {environment} from '../../environments/environment';
|
|
import {first} from 'rxjs/operators';
|
|
|
|
@Injectable({
|
|
providedIn: 'root'
|
|
})
|
|
export class LocationService {
|
|
locations: any = '';
|
|
private locationsList = new BehaviorSubject<any>(this.locations);
|
|
locationsSubject = this.locationsList.asObservable();
|
|
|
|
constructor(
|
|
private http: HttpClient
|
|
) { }
|
|
|
|
getLocations(): void {
|
|
this.http.get(`${environment.cicCacheUrl}/locations`).pipe(first()).subscribe(locations => this.locationsList.next(locations));
|
|
}
|
|
}
|