Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

112
Views
Angular routing with parameter not working

I've installed the new SPA templates for .NET Core, and created a new Angular project. Here is a link if you're interested to give it a go. It comes with an example of routing. Now I am trying to get routing to work with a parameter, but I am having difficulty getting it to work.

In app.module.ts, I am defining the path as follows (with a parameter):

{ path: '', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: HomeComponent },
{ path: 'counter', component: CounterComponent },
{ path: 'fetch-data', component: FetchDataComponent },
{ path: 'fetch-data:id', component: FetchDataComponent },
{ path: '**', redirectTo: 'home' }

And this is how I am defining the router link:

<a [routerLink]="['/fetch-data',3]">
    <span class='glyphicon glyphicon-th-list'></span> Fetch data by ID
</a>

The path shows correct when I hover over the link, but when I click on it, it takes me back to home. I thought maybe it is conflicting with the path above it so I deleted the following line, but still it doesn't work:

{ path: 'fetch-data', component: FetchDataComponent },
over 4 years ago · Santiago Trujillo
1 answers
Answer question

0

Change

{ path: 'fetch-data:id', component: FetchDataComponent },

To

{ path: 'fetch-data/:id', component: FetchDataComponent },
over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!