I have a dependency on fetching a remote JSON config data prior to any routes. What is the recommended way to do so?
Is a guard the recommended way?
I have a dependency on fetching a remote JSON config data prior to any routes. What is the recommended way to do so?
Is a guard the recommended way?
No, guards are for restricting route access to user roles - e.g. guest/customers/admins/etc.
You can use the router.resetConfig() function to change the routes after the initial load. So, you could load the app with a default empty root, then after you've fetched your json, resetConfig() with the new routes.
For example:
let rc: RouterConfig = [
{ path: 'xyz', component: Test },
{ path: 'abc', component: Test },
];
router.resetConfig(rc);