RouterLink breaks routes by replacing ? with %3F
Asked Answered
R

1

6

I have console.log correctly showing the route with customer? however, with the [RouterLink] it is converting it from ? to %3F in which my route no longer works

template html

  <a [routerLink]="[items.Url]">

Route file

 { path: 'customer', component: CustomerComponent, pathMatch: 'full'},

Can I correct this somehow with the template .. routerLink (some pipe filter?) or can or does this have to be fixed in my route module ts file?

HOW?

I need

 http://server/customer?  

but i'm getting

 http://server/customer%3F  
Romance answered 15/12, 2017 at 20:36 Comment(2)
May I ask why you need to add the question mark at the end? If you are building up query parameters, Angular will add the question mark automatically when you specify the parameters.Gnatcatcher
Router link is expecting a list of route segments, not a URL.Gnatcatcher
D
2

You can set query parameters with router link:

<a [routerLink]="[items.url]"
   [queryParams]="{myParam: 'myParamValue'}"
>

This will result in a route as follows:

/server/customer?myParam=myParamValue

Dix answered 28/5, 2020 at 4:50 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.