如何使用角度2在URl中使用questionmark [英] How to use questionmark in URl using angular 2
问题描述
我是Angular 2中的新手
这里显示了我的网址显示的路由器的代码。
路由器代码
现在,当我运行该代码时网址看起来像..
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
localhost:50465/promotion%3Fid%3D/51059
在该网址中显示%3F问号的标记(?)和%3D而不是等于(=)。显示如何显示我的原始网址。我的代码就是这样。
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.
我想这样输出:
http:// localhost:50465 / promotion?id = 132
如何实现这一点请帮助我。
how can acheive this please help me.
请帮帮我.. !!
推荐答案
在您的方案中,您可以使用路由器代码,如下所示:
In your scenario you can use code for router look like this :
{
path: 'home/promotiondetail',
component: component name
}
在您的HTML方面,您可以声明您的路由器代码如下所示:
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
希望,这很有用。
欲了解更多信息,请使用此链接: https:/ /angular2-training-book.rangle.io/handout/routing/routeparams.html
这篇关于如何使用角度2在URl中使用questionmark的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!