Reputation: 1147
I'm new with Angular 4 and I'm trying to create an App with a Dashboard.
User can choose what he want to see on the main dashboard.
In this App, I have to 4 directories : "Dashboard", "Clients", "Products" and "Sales"
Only the 3 last have some service
and module
.
Here is my architecture :
App
|
|__Clients
|__Dashboard
|__Products
|__Sales
If I go to : /*/clients/
=> App display informations about clients only
If I go to : /*/products/
=> App display informations about products only
If I go to : /*/sales/
=> App display informations about sales only
My question : what is the bests practices to display some widgets (clients + products + sales) on my main dashboard without copy/paste my code?
Upvotes: 1
Views: 569
Reputation: 1605
try to import their services into the dashboard component and do what you need
import { ClientService } from './ClientServicePath';
import { ProductsService } from './ProductsServicePath';
import { SalesService } from './SalesServicePath';
constructor(
private clientSer: ClientService,
private productsSer: ProductsService,
private salesSer: SalesService,
) {}
Now simply get data of all the three services and display it in your dashboard
Upvotes: 1