22 lines
640 B
TypeScript
22 lines
640 B
TypeScript
import { Injectable } from '@angular/core';
|
|
import { ActivatedRouteSnapshot, Resolve } from '@angular/router';
|
|
import { Observable, of as observableOf } from 'rxjs';
|
|
|
|
import { Product } from '../core/product';
|
|
import { ProductService } from '../product/product.service';
|
|
|
|
@Injectable({
|
|
providedIn: 'root',
|
|
})
|
|
export class ProductListResolver implements Resolve<Product[]> {
|
|
constructor(private ser: ProductService) {}
|
|
|
|
resolve(route: ActivatedRouteSnapshot): Observable<Product[]> {
|
|
const id = route.paramMap.get('id');
|
|
if (id === null) {
|
|
return observableOf([]);
|
|
}
|
|
return this.ser.listOfSaleCategory(id);
|
|
}
|
|
}
|