angular2 routing - Angular get query params -
i need send next url component:
http://localhost:3000/interactive/malenkoe_obyavlenie?device_type=phone
i tried next:
@ngmodule({ imports: [ routermodule.forchild([ { path: ':id?device_type', component: interactivepreviewcomponent } ]), commonmodule ], declarations: [interactivepreviewcomponent] })
but it's not works. path: ':id/:device_type*',
- in case have worked module brings url format http://localhost:3000/interactive/malenkoe_obyavlenie/phone
upd: goal 'queryparams'.
i found queryparams
in different field of activatedroute:
this.routeparamssubscription = this.route.params.subscribe(params => { //get id params if(params['id']) { this.slug = params['id'] //subscribing change queryparams this.routeparamssubscription = this.route.queryparams.subscribe(params => { // query params this! this.init(this.slug, params['device_type']) }) } })
good tutorial topic: https://angular-2-training-book.rangle.io/handout/routing/query_params.html
Comments
Post a Comment