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