-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