Skip to content

Instantly share code, notes, and snippets.

@ivandotv
Last active August 29, 2015 13:58
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save ivandotv/10023824 to your computer and use it in GitHub Desktop.
Save ivandotv/10023824 to your computer and use it in GitHub Desktop.
Ladda bootstrap integration with Angular
angular.module('uiElements', []).directive('ikiLadda', [function () {
if (typeof Ladda === 'undefined') {
throw new Error('Ladda Library Missing');
// Ladda also depends on Spinner and it will throw error if that library is not present.
}
return {
restrict: 'A',
scope: {
showLoader: '=laddaWatch'
},
link: function (scope, elem) {
var l = Ladda.create(elem[0]);
scope.$watch('showLoader', function (newValue, oldValue) {
if (newValue !== oldValue) {
if (newValue) {
l.start();
}
else {
l.stop();
}
}
})
}
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment