How to use question mark in URl with angular 2

I'm new to Angular 2 Here's the code for a router where my url will be displayed. Router code Now when I run this code the url looks like this.

local: 50465 / promotion% 3Fid% 3D / 51059

In this url, display question mark (?)% 3F instad and% 3D instead of equalto (=). Show how to get my original url display. my code fiber.

I want to output like this: http: // localhost: 50465 / promotion? Id = 132

how can this happen please help me.

Please help me..!!

+3


source to share


1 answer


In your scenario, you can use router code that looks like this:

{       
    path: 'home/promotiondetail',        
    component: component name
}

      

and in your html side you can declare your router code like this:

[routerLink]="['promotiondetail']" [queryParams]="{ id: {{id}} }"

      



is shown when you run this code, you can get the url like this:

http: // localhost: 50465 / promotion? id = 132

Hope this is helpful. For more information use this link: https://angular-2-training-book.rangle.io/handout/routing/routeparams.html

+3


source







All Articles