如何从延迟加载的子组件(在Angular 7中)获取Route Params?

时间:2019-03-20 14:21:10

标签: angular angular-routing angular-router

Angularr route param issues 如何从子组件中获取路线参数(例如,图片中的companyId)? 到目前为止,以下操作无效:

this.companyId = this.route.snapshot.params.companyId;
if (!this.companyId)
    this.companyId = this.route.parent.snapshot.params.companyId;

StackBlitz

1 个答案:

答案 0 :(得分:1)

将选项{paramsInheritanceStrategy: 'always'}添加到您的Router.forRoot()