-1
我需要下一個URL發送到組件:角GET查詢參數
http://localhost:3000/interactive/malenkoe_obyavlenie?device_type=phone
我想未來:
@NgModule({
imports: [
RouterModule.forChild([
{
path: ':id?device_type',
component: InteractivePreviewComponent
}
]),
CommonModule
],
declarations: [InteractivePreviewComponent]
})
,但它不是作品。 path: ':id/:device_type*',
- 在這種情況下,我曾模塊,但它帶來的另一個URL格式 http://localhost:3000/interactive/malenkoe_obyavlenie/phone
UPD:我的目標是獲得「queryParams」。
你不立足*路由*上的查詢參數,它們是額外的信息你從組件中的激活路由中獲得。見例如https://angular.io/guide/router#activatedroute-the-one-stop-shop-for-route-information – jonrsharpe
在AngularJS中,這非常簡單:'$ stateProvider .state('incidents-list',{ url :'/事件?頁面&perPage&on&狀態})',我認爲在Angular2中它也必須起作用。 – kunashir
[Angular 2 Routing based on query params]可能的副本(https://stackoverflow.com/questions/42299753/angular-2-routing-based-on-query-params) – jonrsharpe