如何获取离子对话框中动态加载的元素的元素高度

How to get elements height of an element dynamically loaded inside an ionicdialog

本文关键字:元素 动态 加载 对话框 高度 何获取 获取      更新时间:2023-09-26

我有一个基于模板的模式对话框,我在其中加载GoogleMap。

我希望GoogleMap占据模板中包含的页眉和子页眉下方的剩余空间。

--header——(高度通过css中的mediaquery定义(

--subheader——(高度通过css中的mediaquery定义(

--对话框内的剩余空间

到目前为止,这是我的控制器:

$scope.creategooglemapsmodal = function() {
    $scope.item.showmap = true;
    $ionicModal.fromTemplateUrl('templates/Gmapdialog.html', {
        scope: $scope,
        animation: 'slide-in-up'
    })
        .then(function (modal) {
            $scope.googlemapsmodal = modal;
            $scope.googlemapsmodal.show()
                .then(function() {

//在显示模态之后,我想调整mapcontainers的高度-在我启动映射之前,它将调用容器的高度。

                    $scope.showmapinit();
                    $scope.modalhiddenlistener = $scope.$on('modal.hidden', function() {
                        $scope.hidegooglemapsmodal();
                    });             
                });
        });
};

建议的处理方法是什么?

我找到了一个解决方案:

在GoogleMap初始化后,我调用

map.fitBounds(bounds);

设置缩放和居中(放置标记后(

然后我马上打电话给

$scope.googlemapsmodal.$el.find('.angular-google-map-container').addClass('expander');

CSS如下所示:

.expander {
    position:inherit !important;
    -webkit-transform: none !important;
}

希望这能帮助