akserg / ng2-toasty

Angular2 Toasty component shows growl-style alerts and messages for your app.
MIT License
283 stars 102 forks source link

How do I call the service inside another service. #92

Closed abhishekdgeek closed 7 years ago

abhishekdgeek commented 7 years ago

Hi @akserg,

I was thinking to use this plugin as a general message display for all my API responses. I have a common file which handles all the http request. Can you pl. share some light on how to achieve this?

I am attaching my code snippet below, the place I want to use this plugin issomewhere above - this.logout();

// Interceptor for response
  public interceptAfter(response: InterceptedResponse): InterceptedResponse {
    if (response.response.status === 401) {
      this.logout();
    }
    // Do whatever with response: get info or edit it
    this.loaderService.showLoader.next(false);
    return response;
  }

Thanks, Abhishek Jain

abhishekdgeek commented 7 years ago

Got it working, was able to use the sample code, missed to include the directive in template at global level. 😅