Normally I use this kind of routing to load my components in app-routing.module.ts
const routes: Routes = [
{
path: '', component: HomeComponent
},
{
path: 'product-list', component: ProductListComponent
},
{
path: 'product', component: ProductComponent
}
];
But, I would like to base the routing on a http call to determine what component to load
For a example, I want to be able to have these URL's:
/nike
/nike-airmax
The first URL should load a product list page, and the second a product page
I have a http call to get the page type, it looks like this:
this.http.get(domain + 'api/ApiRoute?url=' + this.activatedRoute
(returns a int value, but it can return whatever I need)
Problem 1
I don't know how to call a service (that returns the type) from app-routing-module.ts
Problem 2
I don't know how to use the "type" from the service to determine the routing