ANTON072
8/27/2014 - 2:59 AM

Bootstrapのmodalを画面中央に表示するためのAngularJS Directive。要jQuery

Bootstrapのmodalを画面中央に表示するためのAngularJS Directive。要jQuery

angular.module('ModalCenter', []).directive('modalDialog', function($window) {
  return {
    restrict: 'C',
    link: function(scope, element, attrs) {
      var win = $($window);
      win.on('resize', modalCenter);
      function modalCenter() {
        element.css('margin-top', (win.height() - element.height()) * 0.5 + 'px');
      }
      modalCenter();
    }
  }
});