I use angular2 guards in this case authGuard, which looks like this:
let isLoggidIn:boolean = false;
this.userService.isUserLoggedIn$.subscribe(param
=> { isLoggidIn = param; })
if(isLoggidIn) {
return isLoggidIn;
} else {
this.router.navigate(['/home']);
return isLoggidIn;
}
and I have http request, which initialize user is logged in or not. When I
boostrap app before resolve http request, authGuard is called and it's
redirected on home page. I want guard to be called after http request.
After this one I tried return Observable :
return this.userService.isUserLoggedIn$.map(param => {
if(param)
return true;
else {
this.router.navigate(['/home'])
return false
}
}).take(1)
cause this subscription is called once, after login request another pages,
which are depended on authGuard are not navigated. I tried all kind of
subjects, but it not working.
--
You received this message because you are subscribed to the Google Groups
"AngularJS" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/angular.
For more options, visit https://groups.google.com/d/optout.