Routing configuration design patterns
Routing configuration can be defined based on different strategies depending upon the complexity of the application. If this is a small application, route definitions can be defined either in root module such as AppModule (app.module.ts) or another routing module (such as app-routing.module.ts) at the root level which is later imported in AppModule. If it is a complex or an enterprise app having several features and each of those features has- its route definitions, it is recommended to define routing at feature module level.
In this section, we will learn about some of the following techniques for routing:Â
- Routing within AppModule
- Routing as a separate module at the app root level
- Routing within feature modules
Routing within AppModule
The most trivial way of configuring route definitions is to create route definitions within the AppModule file, for example, app.module.ts. This technique may only seem to be OK for learning purposes. When creating complex...
 
                                             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
             
     
         
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                 
                