【发布时间】:2020-02-14 00:00:51
【问题描述】:
<app-example [id]="requestId"></app-example>
我们已经在另一个组件中添加了选择器并传递了 id。
export class exampleComponent implements OnInit {
@Input() id:number;
Id:string;
}
constructor(private fb: FormBuilder, private _AppService: AppService, private router: Router, private route: ActivatedRoute) {
this.router.getCurrentNavigation().extras.state != undefined ? this.Id = this.router.getCurrentNavigation().extras.state.key : '';
this.route.data.subscribe(data => {
this.current_path = data.urlname;
})
}
我们使用了 getCurrentNavigation() 方法, 但它返回空值
【问题讨论】:
-
查看此解决方案。可能与stackoverflow.com/questions/54891110/… 重复
标签: javascript angular typescript