loading.js 1.3 KB

1234567891011121314151617
  1. app.directive('loading', function() {
  2. return {
  3. restrict: 'E',
  4. transclude: true,
  5. template: '<div ng-show="loading" class="loading" id="allDiv" style="position:fixed; top:0px; left:0px; width:100%; height:100%; display:none; background-color: rgba(0,0,0,0.5); z-index:99999;">' +
  6. '<div style="vertical-align: middle;width:340px; border-radius: 2px;height:40px;background:#fff; position: absolute; top:50%; left:50%; margin-top: -50px; margin-left:-50px;"><div style="vertical-align: middle;width:60px;float:left; height:40px;margin-top:-10px; "><img alt="" src="assets/images/cmdb/loading.gif" style="vertical-align: middle;width:60px; height:60px; position: absolute; "/></div><div style="vertical-align: middle;width:280px; height:40px; float: right;"><div style="font-size:14px;padding-top:10px;padding-bottom:10px">正在努力加载中,请暂时不要离开此界面...</div></div></div></div>',
  7. link: function(scope, element, attr) {
  8. scope.$watch('loading', function(val) {
  9. if (val) {
  10. document.getElementById("allDiv").style.display = "block";
  11. } else {
  12. document.getElementById("allDiv").style.display = 'none';
  13. }
  14. });
  15. }
  16. }
  17. });