How to use questionmark in URl using angular 2

2019-02-15 10:25发布

I am new in Angular 2 Here, shown code for router where my url would be display. Router Code Now, When I run that code the url look like this..

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

In that url display %3F instad of question mark(?) and %3D instead of equalto(=) .show how to get display my original url. my codelook like that.

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

how can acheive this please help me.

please help me..!!

1条回答
霸刀☆藐视天下
2楼-- · 2019-02-15 10:50

In your scenario you can use code for router look like this :

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

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

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

show when you run this code you can get url look like this :

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

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

查看更多
登录 后发表回答