【问题标题】:Determining Angular UI modal height programmatically以编程方式确定 Angular UI 模态高度
【发布时间】: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);

    }
  }
});

【问题讨论】:

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


【解决方案1】:

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

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

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2018-02-18
    • 2020-05-31
    • 2019-08-06
    • 1970-01-01
    • 1970-01-01
    • 2019-11-23
    相关资源
    最近更新 更多