File size: 721 Bytes
f61d311 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 |
import { Injectable } from '@angular/core';
import { HttpClient } from '@angular/common/http';
import { BehaviorSubject, Observable } from 'rxjs';
import { environment } from './../environments/environment';
export interface Predictions {
[k: string]: {
predicted: number;
actual: number | null
}
}
@Injectable({
providedIn: 'root'
})
export class PredictionsService {
public $predictions = new BehaviorSubject<Predictions>({})
constructor(private http: HttpClient) { }
public getPredictions(targetDate: string): void {
this.http.get<Predictions>(`${environment.apiUrl}/predictions`, { params: { target_date: targetDate }}).subscribe(data => {
this.$predictions.next(data)
})
}
}
|