How to use questionmark in URl using angular 2

我的未来我决定 提交于 2019-12-03 21:33:45

问题


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:


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



来源:https://stackoverflow.com/questions/43999413/how-to-use-questionmark-in-url-using-angular-2

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!