Madhu Sudhanan
May 20, 2022

--

Nothing is a bad example If its working :-). There is always a better solution than the other. I found this approach during my exploration; I feel there is nothing wrong about letting it know to the community by adding a post and also I am not recommending this approach.

By the way, as you told using guard is indeed a good approach but it still making a module associate with one route path, what if the user doesn’t want to associate module with a route path. Just wanted to conditionally change modules for the same route.

For this case, I am not suggesting my approach but its one of the solutions. I would recommend adding factory function for the Routes. You can check out the fantastic blogpost by Netanel Basal.

https://netbasal.com/conditionally-load-a-module-using-angular-router-aff022923850

--

--

Madhu Sudhanan
Madhu Sudhanan

Written by Madhu Sudhanan

Software developer and a blogger. Fond of Angular, React, Vue and Blazor frameworks. Follow me on Twitter — @maddydeep28. PortFolio — https://madhust.github.io/

Responses (1)