How can I access them together in one subscription?
You can use ActivatedRouteSnapshotfrom your own ActivatedRoute. ActivatedRouteSnapshothas the property paramsand queryParams, and you can get both values at the same time. Note: we get only the initial value of the parameters using this technique
constructor(private _route: ActivatedRoute) {
console.log(this._route.snapshot.params);
console.log(this._route.snapshot.data);
}
Plunker example
, params data observable, zip , . , params data , .
this._route.params
.zip(this._route.data)
.subscribe((value) => {
this.id = value[0]["id"];
this.data = value[1];
});
Plunker
angular 2 ?
, , , .