防止Angular2路由器在URL中显示params

时间:2016-12-13 09:20:07

标签: angular angular2-routing

是否可以阻止在URL中显示路径参数?

showProfile(customer){
   this.router.navigate(['profile/' + customer.id, customer]);
}

结果:

http://localhost:3000/profile/10083;id=10083;company=AG...

我问,因为它在重新加载时崩溃了我的应用程序。

Error: Cannot match any routes.

修改

routing.ts

export const routes: Routes = [
  { path: '', redirectTo: '/customers', pathMatch: 'full' },
  { path: 'profile/:id', component: CustomerProfileComponent },
  { path: 'customers', component: CustomerListComponent },
];

export const routing: ModuleWithProviders = RouterModule.forRoot(routes);

0 个答案:

没有答案