如何在Angular 2中获取route参数?(RC-稳定-路由器)

如何在Angular 2中获取route参数?(RC-稳定-路由器),angular,Angular,我正在使用新的稳定角度2 RC版本。新路由器组件的文档尚未编写。我正在努力从导航到的页面中获取参数 我的路线: @Routes([ {path: '/results', component: ResultListComponent}, {path: '/result-detail/:id', component: ResultDetailComponent} ]) 我正在使用以下工具导航到我的详图构件: this.router.navigate(['/result-detail',

我正在使用新的稳定角度2 RC版本。新路由器组件的文档尚未编写。我正在努力从导航到的页面中获取参数

我的路线:

@Routes([
  {path: '/results', component: ResultListComponent},
  {path: '/result-detail/:id', component: ResultDetailComponent}
]) 
我正在使用以下工具导航到我的详图构件:

this.router.navigate(['/result-detail', result.primary_id]);

最后,我不知道如何使用“RouteSegment”在result detail组件中获取主id

在Angular RC1路由器中,您需要使用组件实现接口来获取路由参数:

import { Router, OnActivate, RouteSegment, RouteTree } from '@angular/router';


Component({
...
})
export class ResultDetailComponent implements OnActivate {
    constructor() { }

    routerOnActivate(curr: RouteSegment, prev?: RouteSegment, currTree?: RouteTree,
                     prevTree?: RouteTree) {
        this.id = curr.getParam('id'),
}

对不起,应该提到的是,这相当于不推荐使用的路由器中的RouteParams。编辑:我可能错了,可能根本没有路线图。请参阅下面的评论。当前路由器AFAIK中没有
RouteParams
。我想他们已经在最新的一个中删除了它,但从这个链接中,我认为它以前就在那里:。好的,太棒了,谢谢你清理它。我刚刚也读了你的第一条评论。我将使用不推荐使用的路由器,直到新路由器出厂。谢谢你,甘特!