title: angular 4 loading.dismiss() not working
body: <p>I am trying to do loading.dismiss() inside handleError() method , but not sure how to do?
  it is perfectly working while the response is good, not sure how to handle error case</p>
  
  <p>please help</p>
  
  <pre><code>@Injectable()
  </code></pre>
  
  <p>export class SharedProvider {</p>
  
  <pre><code> private _postsURL = "https://jsonplaceholder.typicode.com/posts";
  
   constructor(private http: Http, public loadingCtrl: LoadingController) {
   }
  
  
  
   getPosts(): Observable&lt;IPosts[]&gt; {
  
      let loading = this.loadingCtrl.create({
          content: 'loading...'
        });
        loading.present();
       return this.http
           .get(this._postsURL)
           .map((response: Response) =&gt; {
              loading.dismiss();
              console.log("Result printed!!");
               return &lt;IPosts[]&gt;response.json();
  
           })
           .catch(this.handleError);
  
  
   }
  
    handleError(error: Response) {
        this.loading.dismiss();
       console.log("Err printed!!" + error.statusText);
       return Observable.throw(error.statusText);
   }
  </code></pre>
  
  <p>}</p>