以编程方式确定角度UI模式高度

时间:2017-12-01 15:03:05

标签: angularjs angular-ui-bootstrap angular-ui

In this plunk我有一个Angular UI模式,带有一个警告弹出窗口,可以显示模态高度。相反,它显示一个空变量。哪里出错?

HTML

 <div the-modal></div>

的Javascript

var app = angular.module("app", ['ui.bootstrap']);

app.controller("ctl", function($scope, $compile) {});


app.directive("theModal", function($uibModal, $timeout) {
  return {
    restrict: "AE",
    scope: true,
    link: function(scope, element, attrs, ctrl, transclude) {

        scope.instance = $uibModal.open({
          animation: false,
          scope: scope,
          template: 'Some Text',
          appendTo: element
        });

        $timeout(function(){
          alert("Modal height is: " + element.css("height"));
        },500);

    }
  }
});

1 个答案:

答案 0 :(得分:2)

内容已放在div中,modal-dialog类位于指令模态占位符元素内。理想情况下,您应该查看element的内部modal-content类。

element[0].querySelector('.modal-dialog').offsetHeight