【发布时间】:2017-12-01 15:03:05
【问题描述】:
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);
}
}
});
【问题讨论】:
-
element.css用于为您的元素设置 CSS 属性,而不是获取 -
那么我如何获得高度?
标签: angularjs angular-ui-bootstrap angular-ui