Angular router redirects immediately

Discussão em 'Angular' iniciado por user28273827332, Dezembro 16, 2024.

  1. I have a route config:

    {
    path: 'dashboard',
    component: UserDashboardPageComponent,
    title: 'Panel',
    children: [
    {
    path: 'summary',
    component: DashboardSummaryComponent,
    title: 'Podsumowanie',
    },
    {
    path: 'official-exams',
    component: OfficialMaturaExamsComponent,
    title: 'Arkusze maturalne',
    },
    {
    path: 'mock-exams',
    component: MockMaturaExamsComponent,
    title: 'Próbne matury',
    },
    {
    path: 'exams-exercises',
    component: MaturaExamsExcercisesComponent,
    title: 'Zadania maturalne',
    }...


    and then i have a page with router outlet:

    <section class="flex h-[100vh]">
    <app-dashboard-navigation class="min-w-[20rem]"></app-dashboard-navigation>
    <router-outlet></router-outlet>
    </section>


    to navigate i have a card:

    <div
    class="flex gap-5 justify-left items-center text-center pl-5 group hover:cursor-pointer m-3 backdrop-blur-md"
    [routerLink]="route"
    >
    <ng-icon
    class="text-3xl group-hover:text-cyan-600 transition-all duration-300"
    [name]="icon"
    ></ng-icon>
    <p
    class="text-xl font-bold group-hover:text-cyan-600 transition-all duration-300"
    >
    {{ title }}
    </p>
    </div>


    and then:

    @for(opt of menu; track opt){
    <app-dashboard-nav-card
    [icon]="opt.icon"
    [title]="opt.title"
    [route]="opt.route"
    ></app-dashboard-nav-card>
    }


    from the list of items:

    menu: any[] = [
    {
    icon: 'tablerAtom',
    title: 'Arkusze maturalne',
    route: 'official-exams',
    },
    {
    icon: 'tablerPaperclip',
    title: 'Arkusze próbne',
    route: 'mock-exams',
    },
    {
    icon: 'tablerNotebook',
    title: 'Zadania maturalne',
    route: 'exams-exercises',
    },
    ];


    The problem is that when i enter the official-exams (dashboard/official-exams) through the navbar, i get immediately redirected to the 'dashboard' and i have to use browser built in go back to access the resource. I can manually enter the url and it works fine, but when i try to enter any component that should be inside router-outlet i get immediately redirected to dashboard.

    I get no error the url is bad, and after all i can go back to right url. The urls are good, but i get redirected all the time.

    Why? How to fix it?

    Continue reading...

Compartilhe esta Página