Use the fork, Luke. PR without tests will likely not be merged.
To install this library, run:
$ npm install bargz-ng-http-loader --save
What does it do ?
This package provides an HTTP Interceptor, and a spinner component (All from SpinKit at the moment). The HTTP interceptor listens to all HTTP requests and shows a spinner / loader indicator during pending http requests.
Angular 4 / Angular 5
The latest module version compatible with angular 4 is
If you want to use Angular 5, use versions
0.4.0 and above.
If you experience errors like below, please double check the version you use.
ERROR in Error: Metadata version mismatch for module [...]/angular/node_modules/ng-http-loader/ng-http-loader .module.d.ts, found version x, expected y, resolving symbol AppModule in [...]/angular/src/app.module.ts
Requirements - HttpClientModule
Performing http requests with the
HttpClientModule API is mandatory. Otherwise,the spinner will not be fired at all.
See this blog post for an
From your Angular
;;;; <============; <============
or (splitted modules mode for more convenience)
;;;; <============; <============; <============
In your app.component.html, simply add :
Customizing the spinner
You can customize the background-color, the spinner type and the debounce delay (ie. after how many milliseconds the spinner will be displayed, if needed):
To use this syntax, you must reference the
Spinkit const as a public property in your app.component.ts:
The different spinners available are referenced in this class.
Otherwise, you can simply reference the chosen spinner as a simple string:
Defining your own spinner
You can define your own loader component in place of the built-in ones. The needed steps are:
- Create your component
- Add it to the entryComponent definition in your module definition
- Reference your component in a public property in your
- Reference the property in the spinner component like this :
You can also filter the http requests that shouldn't be caught by the interceptor by providing an array of regex patterns:
Manually show and hide the spinner
You can manually show and hide the spinner component if needed. You must use the
SpinnerVisibilityService for this purpose.
Each Spinkit component defined in SPINKIT_COMPONENTS can be used independently.