【发布时间】:2019-12-26 22:24:16
【问题描述】:
我将 Id 作为参数传递给我 mu 路由路径,但是当我提取婴儿车时出现错误。
我尝试使用 route.params.subscribe() 方法抽象参数。
我以键名作为术语传递 ID 的方法
onEdit(id:string) {
console.log(id);
this.router.navigate(['../UpdateOrganization',{ term: id }], { relativeTo: this.route });
}
我的网址如下所示:-
http://localhost:4200/#/dashboard/UpdateOrganization;term=MSI3563
我从 url 中提取查询参数的方法
ngOnInit() {
this.createFormControls();
this.createForm();
this.route.params.subscribe(params => {
if (params['term']) {
this.selectedId = params['term'];
}
});
console.log(this.selectedId);
}
我在控制台中收到以下错误消息
ERROR TypeError: Cannot read property 'params' of undefined
【问题讨论】:
标签: angular routing parameter-passing angular2-routing url-routing