In my component I have something which is basically:
<code>public ngOnInit(): void {
this._user.session$.subscribe((session: UserSession | null) => {
if (session?.appKey) {
// trying this as it was recommended on other posts
this._router.onSameUrlNavigation = 'reload';
this._router.navigate([this._returnUrl]).then(() => {
if (this._router.url !== this._returnUrl)) {
// this should never happen
// only happens on first loading of app
window.location.reload();
}
});
}
})
}
</code>
<code>public ngOnInit(): void {
this._user.session$.subscribe((session: UserSession | null) => {
if (session?.appKey) {
// trying this as it was recommended on other posts
this._router.onSameUrlNavigation = 'reload';
this._router.navigate([this._returnUrl]).then(() => {
if (this._router.url !== this._returnUrl)) {
// this should never happen
// only happens on first loading of app
window.location.reload();
}
});
}
})
}
</code>
public ngOnInit(): void {
this._user.session$.subscribe((session: UserSession | null) => {
if (session?.appKey) {
// trying this as it was recommended on other posts
this._router.onSameUrlNavigation = 'reload';
this._router.navigate([this._returnUrl]).then(() => {
if (this._router.url !== this._returnUrl)) {
// this should never happen
// only happens on first loading of app
window.location.reload();
}
});
}
})
}
On the first load, the this._router.navigate
acts like it worked, but does not navigate away. If I reload, it will work – any idea what I can do so I don’t have to do a manual reload?
angular/router 13.3.11