title: Assignment using then function not working in Angular 2
body: <p>I have below code to assign value to user using then()</p>
  
  <pre><code>this.userService.getUser(username).then(user =&gt; {
          console.log(user); // prints value
          this.user = user;
          console.log("after assign") 
          console.log(this.user) // assignment happens
  
      }, error =&gt; {
          console.log(error)
      })
      console.log(this.user) // it is undefined
  </code></pre>
  
  <p>I checked in console, the last one executes before then().</p>
  
  <p><code>this.userService.getUser()</code> return type is <code>Promise&lt;User[]&gt;</code></p>
  
  <p><a href="https://i.stack.imgur.com/MHzH0.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MHzH0.jpg" alt="console results"></a></p>
  
  <p>why is this happening?</p>
  
  <p>TIA</p>