Angular2如何在URL中传递问号和一些单词 [英] Angular2 how can i pass a question mark and some words in my url

查看:128
本文介绍了Angular2如何在URL中传递问号和一些单词的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

您好,我正在尝试向导航网址中添加一些字符串参数,例如
this.router.navigate(['/ merchant / setpassword?acc ='+ response.infoCode]) ;


,但是当我使用时,将我重定向到


/merchant/setpassword%3Facc%3DeyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJtZXppYW4iLCJjb3VudHJ5IjoiOTYiLCJjcmVhdGVkIjoxNTAwMzExODk2MDQ$b是


/ p>

解决方案

尝试一下,

  this.router.navigate([
'url',{id:'companyId',param1:'value1'
}]);;

检查,
如何在angular 2中处理查询参数


hello i am trying to add some string parameters to the navigation url like this this.router.navigate(['/merchant/setpassword?acc='+response.infoCode]);
but when i am using this is redirecting me to

/merchant/setpassword%3Facc%3DeyJhbGciOiJIUzUxMiJ9.eyJzdWIiOiJtZXppYW4iLCJjb3VudHJ5IjoiOTYiLCJjcmVhdGVkIjoxNTAwMzExODk2MDQ5LC

My problem lies in %3Facc%D i want this to become ?acc=

解决方案

Try this,

this.router.navigate( [
  'url', { id: 'companyId', param1: 'value1'
}]);

Check, How to handle query parameters in angular 2

这篇关于Angular2如何在URL中传递问号和一些单词的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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