0
我想将参数传递给这种格式的一个组件www.domain.com?param=value
,但是Angular继续发送像这样的参数www.domain.com;param=value
。为什么要替换?
为;
?传递params angular 2传统方式
这是我的路线的conf:
const router: Routes = [
{path: '', redirectTo: '/shops', pathMatch: 'full'},
{path: 'shops', component: ShopComponent, canActivate: [AuthManager]},
{path: 'shop/new', component: NewShopComponent, canActivate: [AuthManager]},
{path: 'shop/new/:id', component: NewShopComponent, canActivate: [AuthManager]},
{path: 'login', component: LoginComponent},
{path: 'register', component: RegisterComponent},
{path: '**', component: ShopComponent}
];
,这我怎么值传递
this._router.navigate(['shops', {id: id}]);
如果我通过它像
this._router.navigate(['shops?id=id']);
我得到了一个未定义的路线错误。
如果我使用这种方式 this.router.navigate([ '/商店'], { queryParams:{ID:ID}} ); 我的路线成为/商店; id =“id”< - 这是错误的,我想这个结果:/ shops?id =“id” – user3613976
你可以提供一个plunker?使用queryParams应该导致你正在寻找的URL:/ shops?id =“id”。 – DeborahK