Angular2中的路由器参数 [英] Router Parameter in Angular2

查看:52
本文介绍了Angular2中的路由器参数的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

问题是路由器参数显示在URL中,而我希望路由器参数不显示在URL中?

The problem is that router parameters are showing in URL while I want my router parameter not to show in URL ?

myComponent.ts

myComponent.ts

@RouteConfig([      
        { path: '/routerOne/:myId', component: routerOne, name: "routerOne",useAsDefault: true},
        { path: '/routerTwo/:myId', component: routerTwo, name: "routerTwo"},

])

myComponent.html

myComponent.html

  <a [routerLink]="['routerOne',{myId:this.Id}]">RouterOne</a>
  <a [routerLink]="['routerTwo',{myId:this.Id}]">routerTwo</a>

推荐答案

到目前为止,由于您不想在url中显示数据,因此sharedService可能是最后一个选项. RouteData可以是一个选项,但它是immutable. 请仔细阅读这两个主题.

As of now sharedService can be the last option as you don't want to show data in url. RouteData can be an option but it is immutable. please read this two threads carefully.

https://github.com/angular/angular/issues/6672

https://github.com/angular/angular/issues/6569

这篇关于Angular2中的路由器参数的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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