您如何从延迟加载的子组件(在 Angular 7 中)获取路由参数?
How do you get the Route Params from a Lazy-Loaded child component (in Angular 7)?
如何从子组件获取路由参数(例如图片中的 companyId)?
到目前为止,以下没有奏效:
this.companyId = this.route.snapshot.params.companyId;
if (!this.companyId)
this.companyId = this.route.parent.snapshot.params.companyId;
将选项 {paramsInheritanceStrategy: 'always'}
添加到您的 Router.forRoot()
。
this.companyId = this.route.snapshot.params.companyId;
if (!this.companyId)
this.companyId = this.route.parent.snapshot.params.companyId;
将选项 {paramsInheritanceStrategy: 'always'}
添加到您的 Router.forRoot()
。