大佬教程收集整理的这篇文章主要介绍了Angular 2路由器不能处理传递的多个参数,大佬教程大佬觉得挺不错的,现在分享给大家,也给大家做个参考。
http://plnkr.co/edit/ngNSsKBzAuhaP0EjKVJX?p=preview
onSELEct(crisis: Crisis) { // Navigate with Absolute link //this.router.navigate(['/crisis-center',1]); //this is working. this.router.navigate(['/crisis-center',{ id: '1',id2:'2'}]); //this is not working }
//下面是路线:
//{ path: 'crisis-center/:id',component: CrisisDetailComponent } //-- this is working { path: 'crisis-center/:id /:id2',component: CrisisDetailComponent},// this is not working ngOnInit() { this.sub = this.route .params .subscribe(params => { let id = +params['id']; let id2 = +params['id2']; //Unable to read id and id2 values this.service.getCrisis(id) .then(crisis => { if (crisis) { this.editName = crisis.name; this.crisis = crisis; } else { // id not found this.gotoCrises(); } }); }); }
我有三个分层导航,它从危机中心转移到危机细节,然后从危机细节转移到> transactiondetail.因此,在我导航到危机细节之后,我想通过危机等待和危机等待,以便遍历细节,然后再回到危机清单.
此外,我想隐藏浏览器URL中的URL参数并显示别名,以前用作“as”关键字现在它不起作用.
任何帮助赞赏
this.router.navigate(['/crisis-center',1,2]);
你试图这样做:
this.router.navigate(['/crisis-center',id2:'2'}]); //this is not working
因为您已将对象作为第二个参数传递,所以您传递的是查询参数而不是路由器参数.所以,它的URL是:
localhost:3000/crisis-center;id=1&id2=2
你可以在这里阅读更多相关信息:https://angular.io/docs/ts/latest/guide/router.html#!#query-parameters
以上是大佬教程为你收集整理的Angular 2路由器不能处理传递的多个参数全部内容,希望文章能够帮你解决Angular 2路由器不能处理传递的多个参数所遇到的程序开发问题。
如果觉得大佬教程网站内容还不错,欢迎将大佬教程推荐给程序员好友。
本图文内容来源于网友网络收集整理提供,作为学习参考使用,版权属于原作者。
如您有任何意见或建议可联系处理。小编QQ:384754419,请注明来意。