Angular show spinner for every HTTP request with very less code changes

后端 未结 8 543
Happy的楠姐
Happy的楠姐 2020-12-01 03:08

I am working on an existing Angular application. The version is Angular 4.

The application makes HTTP calls to a REST API from lot of various components.

I w

8条回答
  •  醉酒成梦
    2020-12-01 03:39

    Depends upon the approach you follow to use REST SERVICES

    My approach is

    • Create a component and place it somewhere in the application level.
    • Create a service which has counter with increment and decrements methods.

    • This service should decide to show the loader(component) or not by following the below steps.

      Increase the counter each for one request from the client.

      Decrease the counter on each response success and failure

提交回复
热议问题