Angular2 - return boolean with subscribe to canActivate
<p>I am new in Angular, I need to implement a function that returns true/false, I going to use the return in canActivate guard, but this function consumes a api by http.get, so like the communication is asynchronous this function always return FALSE, because http.get yet is in process.</p>

<p>My class guard:</p>

<pre><code>canActivate(route: ActivatedRouteSnapshot, state: RouterStateSnapshot): boolean {

    let url: string = state.url;


    if (this.loginService.isLoggedIn()) {
        return true;
    }

    this.loginService.redirectUrl = url;

    this.router.navigate(['login']);

    return false;
}
</code></pre>

<p>and function isLoggedIn()</p>

<pre><code>isLoggedIn() {

    let logged: boolean = false;

    this.http.get('api/values', this.httpService.headers())
        .map((res: Response) =&gt; {
            logged = res.json();
        });

    return logged;

}
</code></pre>

<p>I read many questions, but I don't found the answer.</p>