2017-12-01 9 views
1

In this plunkモーダル高さを表示する警告ポップアップを備えた角度UIモーダルがあります。代わりに、空の変数が表示されます。エラーはどこですか?角度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

'element.css'は要素にCSSプロパティを設定するために使用されますが、 – Zooly

+0

は取得できません。どうすれば高さを取得できますか? – ps0604

+0

これを試してください:https://stackoverflow.com/questions/24673418/angularjs-get-element-attributes-values – Danish

答えて

2

コンテンツは、ディレクティブモーダルプレースホルダ要素内modal-dialogクラスでdivの内側に配置されています。理想的にはelementの内部modal-contentクラスを見ているべきです。

element[0].querySelector('.modal-dialog').offsetHeight 
関連する問題