barker/bookie/src/app/discount-report/discount-report-resolver.service.ts

21 lines
757 B
TypeScript
Raw Normal View History

2019-08-21 07:01:52 +00:00
import {Injectable} from '@angular/core';
import {ActivatedRouteSnapshot, Resolve, RouterStateSnapshot} from '@angular/router';
import {Observable} from 'rxjs/internal/Observable';
import {DiscountReport} from './discount-report';
import {DiscountReportService} from './discount-report.service';
@Injectable({
providedIn: 'root'
})
export class DiscountReportResolver implements Resolve<DiscountReport> {
constructor(private ser: DiscountReportService) {
}
resolve(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): Observable<DiscountReport> {
const startDate = route.queryParamMap.get('startDate') || null;
const finishDate = route.queryParamMap.get('finishDate') || null;
return this.ser.get(startDate, finishDate);
}
}