【发布时间】:2019-07-20 07:51:09
【问题描述】:
在最新版本的 Angular 7.2.6 中,我正在尝试在路由器本身中传递数据
this.router.navigate(['other'], {state: {someData: 'qwert'}}
在OtherComponent 文件中,this.router.getCurrentNavigation() 始终返回 null
【问题讨论】:
-
你在哪里调用函数?我认为
ngOnInit()为时已晚,因为导航已经完成github.com/angular/angular/blob/7.2.6/packages/router/src/… -
在
OtherComponent中,并将其修改为constructor中,并且成功了!
标签: angular