I need to check te back-end for authentication status, however te code completes before te observable return is finished. Which would result in an undifined.
You can return the observable as Observable
canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot) {
return this.loginService.isAuthenticated()
.map(status => {
console.log(status);
this.authenticated = status;
return true;
}).catch((err) => {
console.log(err);
return Observable.of(false);
});
}