如何使用 angular 2 在 URl 中使用问号

How to use questionmark in URl using angular 2

我是新来的 Angular 2 在这里,显示了路由器的代码,其中将显示我的 url。 Router Code 现在,当我 运行 代码时 url 看起来像这样..

localhost:50465/促销%3Fid%3D/51059

在那 url 中显示 %3F 而不是问号 (?) 和 %3D 而不是等号 (=)。显示如何显示我的原始 url。我的代码看起来像那样。

我想这样输出: http://localhost:50465/promotion?id=132

如何实现这个请帮助我。

请帮帮我..!!

在您的场景中,您可以使用如下所示的路由器代码:

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

在您的 html 端,您可以声明您的路由器代码如下所示:

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

显示当你 运行 这段代码你可以得到 url 看起来像这样 :

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

希望,这很有用。 有关更多信息,请使用此 link :https://angular-2-training-book.rangle.io/handout/routing/routeparams.html