Created
October 1, 2015 07:32
-
-
Save matthewbednarski/8f8061223bce2ac15995 to your computer and use it in GitHub Desktop.
a spinner directive using bootstrap modal and font-awesome fonts
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(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