Giter Club home page Giter Club logo

ladda-angular's Introduction

license travis bower npm

ladda-angular

Angularjs directive for Ladda button ( <300 bytes ) by @hakimel

Demo

Ladda angular

You can also check live demo on codepen

How to use

Bower

You can Install ladda-angular using the Bower package manager.

$ bower install ladda-angular --save

npm

You can also find ladda-angular on npm.

$ npm install ladda-angular

Create your ladda button

For more information about how to create ladda button please refer ladda button repository.

The code

add the Following code into your document.

<script src="path/ladda-angular.min.js"></script>

module

Add ladda dependency to your module

var myApp = angular.module("app", ["ladda"]);

directive

Add directive ladda-button with your normal ladda button.

<button ladda-button="laddaLoading" data-style="expand-right" class="ladda-button"><span class="ladda-label">Submit</span></button>

Directive attribute should be a scope variable with boolean or number.

  • true == start loading.
  • false == stop loading.
  • number == progress value.

Controller example

app.controller('laddaDemoCtrl', function ($scope, $interval, $timeout) {
    
    // Example without progress Bar
    $scope.showLoading = function () {
        /* 
         Set ladda loading true
         Loading spinner will be shown;
        */
        $scope.laddaLoading = true;
        $timeout(function () {
            
            /*
             Set ladda loading false after 3 Seconds. 
             Loading spinner will be hidden;
            */
            $scope.laddaLoading = false;
        }, 3000);
    };

    // Example with progress Bar
    $scope.loadingWithProgress = function () {
        
        // Set progress 0;
        $scope.laddaLoadingBar = 0;
        
        // Run in every 30 milliseconds
        var interval = $interval(function () {
            
            // Increment by 1; 
            $scope.laddaLoadingBar++;
            if ($scope.laddaLoadingBar >= 100) {
                
                // Cancel interval if progress is 100
                $interval.cancel(interval);
                
                //Set ladda loading false
                $scope.laddaLoadingBar = false;
            }
        }, 30);
    };
});

MIT © Sachin

ladda-angular's People

Contributors

sachinchoolur avatar

Watchers

James Cloos 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.