Created
September 24, 2015 12:56
-
-
Save matthewbednarski/2895fa08c894c5001d5e to your computer and use it in GitHub Desktop.
A bootstap modal with a spinner
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">' + | |
'<div class="modal-content">' + | |
'<div class="modal-body">' + | |
'<i class="fa fa-spinner fa-spin"></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