P
P
prolina2021-02-11 17:09:07
Angular
prolina, 2021-02-11 17:09:07

Routing Angular not working?

Hello. After logging into the system, a certain AdvancesPageComponent page (the /advances route) should be shown to the user, this page is a table, by clicking on the cell, a specific AdvancePageComponent (/advances/:id) should be opened. Also on the AdvancesPageComponent page there is a button

<button
          color="primary"
          class="mr-2"
          mat-raised-button
          routerLink="new-advance"
        >
            New Advance
        </button>

to create a new advance (the route must be advances/new-advance).

In this case, when you click on the creation of a new advance, the correct url is shown, but the content of the AdvancePageComponent page

export const routes: Route[] = [
  {
    path: '',
    component: AdminPortalLayoutComponent,
    children: [
      {
        path: '',
        component: AdvancesPageComponent,
        canActivate: [IsLoggedInGuard],
      },
      {
        path: ':id',
        component: AdvancePageComponent,
        canActivate: [IsLoggedInGuard],
      },
      {
        path: 'new-advance',
        component: NewAdvancePageComponent,
        canActivate: [IsLoggedInGuard],
      },
    ],
  },
];


In AdminPortalLayoutComponent -<router-outlet></router-outlet>

Answer the question

In order to leave comments, you need to log in

4 answer(s)
G
GF, 2021-02-11
@prolina

Because your new-advance line matches :id from the previous route. Move the object for that path up in the array.

A
Amfore, 2017-09-12
Dmitry

I would take the second one. Of course, the absence of an HDD is embarrassing, but with an SSD you will feel the difference in performance.

O
oh, 2017-09-12
well @AnneSmith

macbook pro

Z
Zakhar Kushchenko, 2017-09-12
@ZZahar

HP Pavilion 15-bc206ur Core i5, 16GB RAM, 2TB HDD + 128 SSD, nVidia GeForce GTX 1050.4GB or Lenovo Legion Y520-15IKBN Core i5, 1TB HDD + 128 SSD, 16GB RAM, nVidia GeForce GTX 1050, 4 GB. All these laptops can’t be played for 3 years ahead, and if you don’t play then: Asus ZenBook UX310UA - Core i7, 16GB RAM, 1TB + 128 SSD, Intel HD Graphics 520 or Lenovo IdeaPad 320-15IKB - Core i7, 16GB RAM, 512 SSD, nVidia GeForce GT 940MX, 2 GB.

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question