Angular (typescript) Spinner. Wrapper around spinner: http://spin.js.org/ (<3.0.0 version).
It has dependency on spin.js. It doesn't include it in bundle so you have to isntall it yourself (<3.0.0 until #3 is fixed).
npm install spin.js@2.x --save
npm install ng-ts-spinner --save
In case you are using Angular CLI, add spin.js (it will be downloaded together with ng-ts-spinner module) to your scripts path:
"scripts": ["../node_modules/spin.js/spin.min.js"]
import { NgTsSpinnerModule } from 'ng-ts-spinner';
. . .
@NgModule({
. . .
imports : [
. . .
NgTsSpinnerModule
]
<div ng-ts-spinner [spinOn]="loadingInProgress" [options]="spinnerOptions">
<div>Everything here will be under the spinner</div>
</div>
spinOn - when set to true, spinner spins, when false, spinner is removed
overlayWhileSpin - if true, it will display overlay, making everything non-clickable where it is spinning (make sure parent element has positioning set)
spinnerOptions - options based on options from http://spin.js.org/. It can be empty, it will use defaults
When changing spinnerOptions, spinner should be stopped, and then again spin to apply changes of the options.
Breaking change: Added support for Angular6+. Now only support Angular6+, for below version, use 1.6.x
- New way of installing dependency. Spin.js has to be installed manually (since npm3+ doesn't install dependency automatically).
BREAKING CHANGE: Change the way you import module to:
import { NgTsSpinnerModule } from 'ng-ts-spinner';
- Added support for overlayWhileSpin
- Added index.ts to have nicer import (only name of the module)
- Restricted spin.js dependency to be under 3.0.0 because 3.0.0 removed spin.min.js.
- Spinner doesn't add extra div to the placeholder