Angular2 Call login function from service in component and return error
<p>I'm trying to call a service HTTP method and eventually return an error message but after a week of trying many things (Promises, Observables, ...) I can't get it to work. I hope anybody can help me out?</p>

<p>I'm kind of new to Angular2 and working alone on this project, with no one else around me with any Angular expertise. I did get a 3-day training course.</p>

<p>Component</p>

<pre><code>@Component({
  templateUrl: 'build/pages/login/login.html'
})
export class LoginPage {
  error: string;

  constructor(private navController: NavController, private auth: AuthService) {
  }

  private login(credentials) {
    // Method calling the login service
    // Could return an error, or nothing
    this.error = this.auth.login(credentials);

    // If there is no error and the user is set, go to other page
    // This check is executed before previous login methode is finished...
    if (!this.error &amp;&amp; this.auth.user) {
      this.navController.setRoot(OverviewPage);
    }
  }
}
</code></pre>

<p>AuthService</p>

<pre><code>@Injectable()
export class AuthService {
  private LOGIN_URL: string = "http://localhost:8080/rest/auth";
  private USER_URL: string = "http://localhost:8080/rest/user";

  private contentHeader: Headers = new Headers({
    "Content-Type": "application/json"
  });

  errorMessage: string;
  user: User;

  constructor(private http: Http) {
  }

  login(credentials) {
      let contentHeader = new Headers({
        "Content-Type": "application/json"
      });

    this.http.post(this.LOGIN_URL, JSON.stringify(credentials), { headers: contentHeader })
      .map(res =&gt; res.json())
      .catch(this.handleError)
      .subscribe(
        data =&gt; this.handleLogin(data),
        err =&gt; this.handleError
      );

    // could return an errorMessage or nothing/null
    return this.errorMessage;
  }

  private handleLogin(data) {
    let token = data.token;
    this.getAccount(token);
  }

  private getAccount(token) {
    let authHeader = new Headers({
      "Content-Type": "application/json",
      "X-Auth-Token": token
    });

    this.http.get(this.USER_URL, { headers: authHeader })
      .map(res =&gt; res.json())
      .catch(this.handleError)
      .subscribe(
        data =&gt; this.setUser(data),
        err =&gt; this.errorMessage = err
      );
  }

  private setUser(data) {
    this.user = new User(data.naam, data.voornaam);
  }

  private handleError(error) {
    // this.errorMessage is not saved?

    if (error.status === 401) {
      this.errorMessage = '401';
    } else if (error.status === 404) {
      this.errorMessage = '404';
    } else {
      this.errorMessage = 'Server error';
    }

    return Observable.throw(error.json() || 'Server error');
  }
}
</code></pre>