angular - router.navigate occasionally not changing view -


i'm not sure why, navigation home page after login working times. occasionally, however, app stay on login page , not load home page should.

i added .then , console.logs when failed 'navigation successful' in console. i'm not sure else for. works 75% of time, nothing in console when fails explain why.

when fails there no message in console, no error can see, page view stays on login form, address bar of browser doesn't change , top off toast message right above it. i've tried moving toast after navigate call, , still toast when doesn't navigate. don't think toastservice affecting in way.

public submitlogin(login) { this.loginservice.login(login.value.email, login.value.password) .subscribe( () => { this.toasterservice.pop('success', 'login', 'successfully logged in'); this.router.navigate(['./home']).then( () => console.log('navigation successful'), () => console.log('navigation failed') ); }, err => { this.error = apihelper.builderrorstringfromresponse(this.login.controls, err); } ); }

i found solution because wasn't using .share() , subscribes weren't being executed in fixed order. original http call added .share() before adding subscribes , runs correct.


Comments