Angular2: how to redirect if API returns an error?
<p>In my service, I want to describe a behavior when user is being redirected if not authorized.</p>

<pre><code>export class MessagesService {
    constructor (private http: Http) {}

    private _usersUrl = '/users.json';  // URL to web api


    getUsers() {
        return this.http.get(this._usersUrl)
            .map(res =&gt; &lt;User[]&gt; res.json().data)
            .catch(this.handleError);
    }

    private handleError (error: Response) {

        if (error.status == 401) {
            // How do I tell Angular to navigate LoginComponent from here?
        } else {
            return Observable.throw(error.json().error || 'Server error');
        }
    }
}
</code></pre>

<p>My questions are:</p>

<ul>
<li>Is it even possible?</li>
<li>Is that a good practice?

<ul>
<li>If yes, how do I perform that?</li>
<li>If no, how else can I do that?</li>
</ul></li>
</ul>