Skip to content

Instantly share code, notes, and snippets.

@fcfowler
Created December 9, 2013 01:15
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 fcfowler/7866046 to your computer and use it in GitHub Desktop.
Save fcfowler/7866046 to your computer and use it in GitHub Desktop.
Non gif loading directive using spin.js
app.directive('spinner', ['$window', function ($window) {
return {
scope: true,
link: function (scope, element, attr) {
scope.spinner = null;
function stopSpinner() {
if (scope.spinner) {
scope.spinner.stop();
scope.spinner = null;
}
}
scope.$watch(attr.spinner, function (options) {
stopSpinner();
scope.spinner = new $window.Spinner(options);
scope.spinner.spin(element[0]);
}, true);
}
};
}]);
<span spinner="{radius:5, width:2, length: 4, color: '#fff'}"></span>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment