title: Can not assign observable data to local variable in angular
body: <p><strong>My Service</strong> </p>
  
  <pre><code>import { Injectable } from '@angular/core';
  import {Observable} from 'rxjs';
  import { HttpClient,HttpParams } from '@angular/common/http';
  
  @Injectable()
  export class UserService {
  
    constructor(private http: HttpClient) { }
    isAdmin;
    getLogIn(email:string,password:string):Observable&lt;boolean&gt;{
      let params = new HttpParams().set("userEmail",email).set("userPassword", password);
      return this.http.get&lt;boolean&gt;("http://localhost:8080/user/login",{params: params});
       }
  }
  </code></pre>
  
  <p><strong>My Subscribe call</strong></p>
  
  <pre><code> email:string="";
    password:string="";
    adminFlag:boolean=false;
  
    login(event: any) {
      console.log(this.adminFlag);
      this.userService.getLogIn(this.email,this.password).subscribe(data =&gt; this.adminFlag=(data));
      console.log(this.adminFlag);
      if(this.adminFlag){
        console.log("INSIDE IF")
          this.router.navigate("../../home");
      }
    }
  </code></pre>
  
  <p>When i log in data var in console I am getting raw data as</p>
  
  <pre><code>true
  </code></pre>
  
  <p>but i couldn't assign it to this boolean "adminFlag" it is changed to undefined</p>
  
  <p>Anything I missed...???</p>
  
  <p>the API is returning a boolean..I need that boolean to be assigned...</p>