akserg / ng2-toasty

Angular2 Toasty component shows growl-style alerts and messages for your app.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

How do I call the service inside another service.

abhishekdgeek opened this issue · comments

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

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