angular routing is not working in angular 19

Discussão em 'Angular' iniciado por Indraraj26, Janeiro 12, 2025.

  1. Indraraj26

    Indraraj26 Guest

    Why is this routing config not working? The router is trying to go /posts but it should not go to /posts. Currently it is showing a blank page. BlankComponentComponent contains router-outlet and FullComponentComponent contains header, router-outlet and footer.

    When user is logged in, then it should use BlankComponentComponent router-outlet otherwise it should use FullComponentComponent. I remember I used this to work in Angular 14.

    export const routes: Routes = [
    {
    path: '',
    component: BlankComponentComponent,
    canActivate: [
    () => {
    return true;
    },
    ],
    children: [
    {
    path: '',
    redirectTo: '/auth',
    pathMatch: 'full',
    },
    {
    path: 'auth',
    children: [...authRoutes],
    },
    ],
    },
    {
    path: '',
    component: FullComponentComponent,
    canActivate: [
    () => {
    return false;
    },
    ],
    children: [
    {
    path: '',
    redirectTo: 'posts',
    pathMatch: 'full',
    },
    {
    path: 'posts',
    loadComponent: () =>
    import('./post/posts/posts.component').then((c) => c.PostsComponent),
    },
    ],
    },
    ];

    Continue reading...

Compartilhe esta Página