I am facing an important query. Can we implement async routing in Angular 10? I have come across AsyncRoute in Angular2, but it seems to no longer exist in Angular 10.
Here is a snippet of my code :
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]})
}
})
While this generates a valid and correct Route Array, my issue lies in the fact that this data is asynchronous. Therefore, I cannot directly push the data to the route:Routes Array in app-routing.module.ts using the constructor. Is there another method to accomplish this task? Has anyone encountered similar challenges before?