angular-tailwind
angular-tailwind copied to clipboard
Refactor: Improve routing structure for standalone and module-based components
Refactored Routing to Support Standalone Components
Summary of Changes
- Refactored routing to properly nest components inside
LayoutComponent. - Ensured support for both standalone components and lazy-loaded modules.
- Updated wildcard redirect to maintain consistency.
- No need to use modules and routing modules to add new components—standalone components can be integrated directly.
Adding More Components is Easy
Just use loadComponent like this:
const routes: Routes = [
{
path: '',
component: LayoutComponent,
children: [
{
path: 'dashboard',
loadChildren: () => import('../dashboard/dashboard.module').then(m => m.DashboardModule),
},
{
path: 'components',
loadChildren: () => import('../uikit/uikit.module').then(m => m.UikitModule),
},
{
path: 'new-feature',
loadComponent: () => import('../new-feature/new-feature.component').then(m => m.NewFeatureComponent),
}
],
},
{ path: '**', redirectTo: 'error/404' },
];
Hello Alan Melendez, 👋 Please check the preview of your PR on Vercel: https://angular-tailwind-ekhv45qjx-lannos-projects.vercel.app/
❗Your changes will break the application.
Note: The main route should be the dashboard module.