I am trying to subscribe to both route data and route params in Angular. I am using Observable.zip
, but unfortunately subscribe function isn't trigger when I switch routes (I have routes A, B, C and D which has a parameter in URL).
My code looks as follows:
ngOnInit() {
this.subscription = Observable.zip(this.route.data, this.route.params)
.subscribe(([data, params]) => {
// do something...
});
}
However, when I use these piece of code:
this.route.params.subscribe((data) => {
// do something...
})
Everything works fine and I am able to subscribe to params. I want to do this using only one subscription.