An angular directive wrapper for Ladda.
$scope.loading.items = [];
for(var i=0; i<20; i++) {
$scope.loading.items.push({ name: 'item ' + i, loading: false });
}
$scope.clickArrayBtn = function(idx) {
$scope.loading.items[idx].loading = true;
$timeout(function() {
$scope.loading.items[idx].loading = false;
}, 2000);
};
(1) Get angular-ladda via Bower
$ bower install angular-ladda
or add bower.json
$ bower install angular-ladda --save
(2) add css & javascript link to html
...
<link rel="stylesheet" href="bower_components/ladda/dist/ladda-themeless.min.css">
...
<script src="bower_components/ladda/js/spin.js"></script>
<script src="bower_components/ladda/js/ladda.js"></script>
<script src="bower_components/angular-ladda/dist/angular-ladda.min.js"></script>
...
(3) add 'angular-ladda' to your main module's list of dependencies
var myApp = angular.module('myApp', ['angular-ladda']);
set true
value
<button ladda="true">Button</button>
set false
value
<button ladda="false">Button</button>
set float
value
<button ladda="0.1">Button</button>
$scope.clickBtn = function() {
$scope.loading = true; // start loading
$timeout(function() {
$scope.loading = false; // stop loading
}, 2000);
}
<button ladda="loading" ng-click="clickBtn()">
Button
</button>
use data-style
attribute
<button ladda="loading" ng-click="clickBtn()" data-style="expand-right">
Button
</button>
use data-spinner-size
attribute
<button ladda="loading" ng-click="clickBtn()" data-spinner-size="30">
Button
</button>
use data-spinner-color
attribute
<button ladda="loading" ng-click="clickBtn()" data-spinner-color="#000000">
Button
</button>