0

I have a button that should take the user to the previews page.

I'm at #/country/2 - 2 being an idx When I click the button below it sends me to: #/country/2/brands, when it should be #/brands

<a [routerLink]="['brands']"><input value="sub" type="submit"></a>

I have imported router and ActivatedRoute. I have more routes working but not this one. Any suggestion will be welcomed.

Tibebes. M
  • 6,940
  • 5
  • 15
  • 36
genius
  • 45
  • 4

1 Answers1

0

What's happening right now is that it's accessing relative path. Since you are at #/country/2/, with ['brand'], you will definitely be directed to #/country/2/brands and that is the expected behavior of your code.

Here's a very good explanation of the different routerLink parameter formats: routerLink absolute url

If #/brands is from the root of your application, you simply need to use:

<a [routerLink]="['/brands']"><input value="sub" type="submit"></a>
Algef Almocera
  • 759
  • 1
  • 6
  • 9