Giter Club home page Giter Club logo

angular-spinner's Introduction

angular-spinner

Angular directive to show an animated spinner (using spin.js)

Copyright (C) 2013, 2014, Uri Shaked [email protected].

Build Status Coverage Status

Usage

Include both spin.js and angular-spinner.js in your application.

<script src="bower_components/spin.js/dist/spin.js"></script>
<script src="bower_components/angular-spinner/angular-spinner.js"></script>

Add the module angularSpinner as a dependency to your app module:

var myapp = angular.module('myapp', ['angularSpinner']);

You can now start using the us-spinner directive to display an animated spinner. For example :

<span us-spinner></span>

You can also pass spinner options, for example:

<span us-spinner="{radius:30, width:8, length: 16}"></span>

Possible configuration options are described in the spin.js homepage.

Using the usSpinnerService to control spinners

<button ng-click="startSpin()">Start spinner</button>
<button ng-click="stopSpin()">Stop spinner</button>

<span us-spinner spinner-key="spinner-1"></span>

The usSpinnerService service let you control spin start and stop :

app.controller('MyController', ['$scope', 'usSpinnerService', function($scope, usSpinnerService){
    $scope.startSpin = function(){
        usSpinnerService.spin('spinner-1');
    }
    $scope.stopSpin = function(){
        usSpinnerService.stop('spinner-1');
    }
}]);

Note that when you specify a key, the spinner is rendered inactive. You can still render the spinner as active with the spinner-start-active parameter :

<span us-spinner spinner-key="spinner-1" spinner-start-active></span>

The spinner-key will be used as an identifier (not unique) allowing you to have several spinners controlled by the same key :

<span us-spinner spinner-key="spinner-1"></span>
<span us-spinner spinner-key="spinner-2"></span>

... random html code ...

<!-- This spinner will be triggered along with the first "spinner-1" -->
<span us-spinner spinner-key="spinner-1"></span>

Example

See online example on Plunker.

License

Released under the terms of MIT License.

angular-spinner's People

Contributors

aaronroberson avatar elfreyshira avatar floribon avatar idanb11 avatar jdamick avatar lossendae avatar spieszko avatar urish avatar vleborgne avatar

Stargazers

 avatar

Watchers

 avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.