angular-tailwind icon indicating copy to clipboard operation
angular-tailwind copied to clipboard

Refactor: Improve routing structure for standalone and module-based components

Open AlanMelendez opened this issue 11 months ago • 1 comments

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' },
];

AlanMelendez avatar Feb 21 '25 05:02 AlanMelendez

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.

lannodev avatar Feb 21 '25 19:02 lannodev