Trying to handle an OAuth login scenario where if the user lands on a page with authorization_code in the query string, we process the token and continue
The best way to overcome this was subscribing router events, and processing query params only after the route is ticked to navigated state:
public doSomethingWithQueryParams(): Observable {
let observer: Observer;
const observable = new Observable(obs => observer = obs);
this.router.events.subscribe(evt => {
// this is an injected Router instance
if (this.router.navigated) {
Observable.from(this.activatedRoute.queryParams)
// some more processing here
.subscribe(json => {
observer.next(json);
observer.complete();
});
}
});
return observable;
}