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);
}
}
});
答案 0 :(得分:2)
内容已放在div中,modal-dialog
类位于指令模态占位符元素内。理想情况下,您应该查看element
的内部modal-content
类。
element[0].querySelector('.modal-dialog').offsetHeight