如何使用 angular 2 在 URl 中使用问号 [英] How to use questionmark in URl using angular 2

查看:22
本文介绍了如何使用 angular 2 在 URl 中使用问号的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我是 Angular 2 的新手在这里,显示了我的 url 将显示的路由器代码.路由器代码现在,当我运行该代码时,网址如下所示..

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..

本地主机:50465/promotion%3Fid%3D/51059

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

在那个 url 显示 %3F instad 的问号 (?) 和 %3D 而不是 equalto(=) .show 如何显示我的原始 url.我的代码就是这样.

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://angular-2-training-book.rangle.io/handout/routing/routeparams.html

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

这篇关于如何使用 angular 2 在 URl 中使用问号的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆