Migrate to HttpClient in Operation module.
This commit is contained in:
@ -5,14 +5,14 @@ import * as moment from 'moment';
|
||||
import { Injectable } from '@angular/core';
|
||||
import { Observable } from 'rxjs/Rx';
|
||||
|
||||
import { Restangular } from "ngx-restangular";
|
||||
import { HttpClient, HttpParams } from "@angular/common/http";
|
||||
|
||||
import { Category } from './category';
|
||||
|
||||
@Injectable()
|
||||
export class CategoryService {
|
||||
constructor(
|
||||
private restangular: Restangular
|
||||
private http: HttpClient
|
||||
) {}
|
||||
|
||||
formatDate(date: Date|string) {
|
||||
@ -24,16 +24,16 @@ export class CategoryService {
|
||||
}
|
||||
|
||||
query(id: number, minDate: Date = null, maxDate: Date = null): Observable<Category[]> {
|
||||
var dateRange: any = {};
|
||||
let params: HttpParams = new HttpParams();
|
||||
|
||||
if(minDate) {
|
||||
dateRange.begin = this.formatDate(minDate);
|
||||
params = params.set('begin', this.formatDate(minDate));
|
||||
}
|
||||
|
||||
if(maxDate) {
|
||||
dateRange.end = this.formatDate(maxDate);
|
||||
params = params.set('end', this.formatDate(maxDate));
|
||||
}
|
||||
|
||||
return this.restangular.one('account', id).getList('category', dateRange);
|
||||
return this.http.get<Category[]>(`/api/account/${id}/category`, { params: params});
|
||||
}
|
||||
}
|
||||
|
Reference in New Issue
Block a user