Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

@matthewbednarski
Created October 1, 2015 07:32
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 matthewbednarski/8f8061223bce2ac15995 to your computer and use it in GitHub Desktop.
Save matthewbednarski/8f8061223bce2ac15995 to your computer and use it in GitHub Desktop.
a spinner directive using bootstrap modal and font-awesome fonts
(function() {
var app = angular.module('mcbSpin', [])
.directive('spinner', [Spinner]);
function Spinner() {
return {
restrict: 'EA', //E = element, A = attribute, C = class, M = comment
scope: {
//@ reads the attribute value, = provides two-way binding, & works with functions
show: '@',
},
template: '<div id="spinnerModal" class="modal fade">' +
'<div class="modal-dialog spinner">' +
'<div class="modal-content">' +
'<div class="modal-body">' +
'<i class="fa fa-spinner fa-spin fa-5x"></i>' +
'</div>' +
'</div>' +
'</div>' +
'</div>',
link: function(scope, element, attrs) {
scope.$watch('show', function(n, o) {
if (n === 'true') {
$('#spinnerModal').modal('show');
console.log(o + '-->' + n);
} else if(n === 'false') {
$('#spinnerModal').modal('hide');
console.log(o + '-->' + n);
}
}, true);
} //DOM manipulation
};
}
})();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment