I have a reusable component and I need to use its get()
method in order tp retrieve data from server viw different services. When I use this reusable component in Employee components, it will use the get method of employeeService and similarly when I use it in Product components it will use the get method of productService. I think I may inject the service to the reusable component's constructor and call the related service by using this. But I am not sure if there is a better way to call the method and retrieve the resultset. Any help would be appreciated.
constructor(private productsService: ProductsService) {}
ngAfterViewInit() {
const data = this.get();
}
get() {
return this.productsService.Products("id", "ASC", this.paginator.pageIndex+1);
}
Aucun commentaire:
Enregistrer un commentaire