# sarsha-loading-spinner

Latest version **1.0.0** (published 2016-11-09) · ISC license · 0 weekly downloads

## Install

```sh
npm install sarsha-loading-spinner
pnpm add sarsha-loading-spinner
yarn add sarsha-loading-spinner
bun add sarsha-loading-spinner
```

## Health

**Score 15/100 (F)** — status: abandoned.

Positive: no vulnerabilities.

Warnings: low downloads; no types; no esm support.

Negative: abandoned; low maintenance score.

## Facts

| | |
|---|---|
| Version | 1.0.0 |
| Published | 2016-11-09 |
| First published | 2016-11-09 |
| Weekly downloads | 0 |
| License | ISC |
| TypeScript types | none |
| Module format | CommonJS |
| Dependencies | 2 |
| Known vulnerabilities | 0 (+10 in 1 direct dependencies) |
| Install scripts | no |
| GitHub stars | 7 |
| Author | Matan SarSha |
| Maintainers | msarsha |

## Links

- npm: https://www.npmjs.com/package/sarsha-loading-spinner
- Repository: https://github.com/msarsha/angular-loading-spinner
- Homepage: https://msarsha.github.io/angular-spinner
- Issues: https://github.com/msarsha/angular-loading-spinner/issues
- npm.io page: https://npm.io/package/sarsha-loading-spinner

## Dependencies (2)

- [angular](https://npm.io/package/angular.md) ^1.5.8
- [angular-animate](https://npm.io/package/angular-animate.md) ^1.5.8

## Recent versions

- 1.0.0 (latest) — 2016-11-09

## README

# angular-loading-spinner
Loading spinner for AngularJS

__DEMO:__ https://msarsha.github.io/angular-spinner/

### Install:
`npm i sarsha-loading-spinner --save`

### Build:
Clone the repo and run `npm install` to install dependencies and then `gulp` to build;

### Dependencies:
`angular-animate`

### Setup:

add spinner module as dependency
````javascript
angular.module('app', ['sarsha.spinner'])
````
load angular-animate in your html
````html
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.5.8/angular-animate.min.js"></script>
````


### How to use:

Use the default spinner template

````html
<div>
  Your content here
  <sarsha-spinner name="spinner1"></sarsha-spinner>
</div>
````

Use your own template:

````html
<div>
  Your content here
  <sarsha-spinner name="spinner1">
    <div>
      <span>MY OWN TEMPLATE !!</span>
    </div>
  </sarsha-spinner>
</div>
````

Place as many spinners as you like
````html
<div>
  Your content here
  <sarsha-spinner name="spinner1"></sarsha-spinner>
</div>
<div>
  Your content here
  <sarsha-spinner name="spinner2"></sarsha-spinner>
</div>
````

### Controlling the Spinners

#### Manualy control the spinners using the `spinnerService`

````javascript
  angular.controller('ctrl', function(spinnerService){
    this.doSomething = function(){
      spinnerService.show('spinner1'); 
      // or to show all
      spinnerService.showAll();
    }
    
    this.dontDoSomething = function(){
      spinnerService.close('spinner1');
      // or to close all
      spinnerService.closeAll();
    }
  })
````

#### Let the `spinnerHttpInterceptor` control the spinners

Add the `spinnerHttpInterceptor` to your module config
````javascipt
  angular
    .module('app', [])
    .config(function($httpProvider){
      $httpProvider.interceptors.push('spinnerHttpInterceptor');
    })
````

The default behavior of the `spinnerHttpInterceptor` is to show and close all existing spinners.

You can tell it which spinner is related to the http request by adding the `spinner` object to the `$http` config.

The `spinner` object can be either a `string` for a single spinner or an `Array` for number of spinners.

````javascript
  angular.controller('ctrl', function($http){
    this.doSomething = function(){
      $http.get('http://url.com', {
        spinner: 'spinner1'
      }) 
    }
    
    this.doSomething = function(){
      $http.get('http://url.com', {
        spinner: ['spinner1', 'spinner2']
      }) 
    }
  })
````

---
_Source: https://npm.io/package/sarsha-loading-spinner · Machine-readable twin of the npm.io package page. Health data is recomputed on every publish._
