angular2 rc6:类型RouterState上不存在属性queryParams

时间:2016-09-06 08:35:31

标签: angular

另一个" Deprecation-Now-Error"在角度2决赛的道路上。

错误信息很明确,我只需要知道现在调用相应字段的内容。任何人

  

属性queryParams在RouterState

类型上不存在

3 个答案:

答案 0 :(得分:13)

认为我解决了它:属性“queryParams”现在位于Routerstate的属性“root”上:

this.router.routerState.root.queryParams

答案 1 :(得分:9)

可能你正在使用:

router: Router

您可以将其更改为:

activatedRoute: ActivatedRoute

然后访问queryParams:

this.activatedRoute.queryParams

答案 2 :(得分:0)

以下是快照版本

constructor(
    private route: ActivatedRoute,
    private router: Router
) {}

而不是

this.router.routerState.snapshot._root.value.queryParams;

我做了这个

this.route.snapshot.queryParams;