如何在角度ui/bootstrap设置100%高度响应



我正在使用这个库:https://angular-ui.github.io/bootstrap/并且我需要将我计算的面板体高度设置为Accordion。

我有$window resize事件的父div指令,但我需要在页面加载时设置子元素的高度&调整大小。

如何设置元素的自定义高度?感谢

以下是示例:

angular.module(‘app’)
            .directive('calculateHeight', calculateHeight);
        function calculateHeight($window) {
            return function (scope, element) {
                var w = angular.element($window);
                scope.getWindowDimensions = function () {
                    return { 'h': $window.outerHeight, 'w': $window.outerWidth };
                };
                scope.$watch(scope.getWindowDimensions, function (newValue, oldValue) {
                    scope.windowHeight = newValue.h;
                    scope.windowWidth = newValue.w;
                    var matches = document.querySelectorAll(“div.panelBody”); // use selector to the element
                    matches[0].style.height = yourCustomHeight;
                }, true);
                w.bind('resize', function () {
                    scope.$apply();
                });
            };
        }

最新更新