So I have an important Question. Is it possible to achieve async routing in Angular 10 ?
I have read about the AsyncRoute in Angular2, but this one doesn't exist anymore in Angular 10.
My Code looks like this :
getRoutes() {
return this.http.get(this.APIROOT + 'routes');
}
pageService.getRoutes().subscribe( (pageRoutes:RouteInterface[]) => {
const componentMap = {
'PageComponent': PageComponent,
'BlogComponent':BlogComponent
};
for(let route of pageRoutes){
this.routes.push({ 'path' : route.route, 'component' : componentMap[route.component]})
}
})
This will result in an valid and correct :Route Array. My Problem is that this Data isnt synchronous. Its asynchronous. So i cant just push the data to the route:Routes Array in the app-routing.module.ts via the constructor.
Is there any other way to achieve this ? Does anyone has experience with that ?