Warning: file_get_contents(/data/phpspider/zhask/data//catemap/6/EmptyTag/129.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Angularjs 带角度滑块的高度问题_Angularjs - Fatal编程技术网

Angularjs 带角度滑块的高度问题

Angularjs 带角度滑块的高度问题,angularjs,Angularjs,我正在使用angularlideables: 我遇到了一个问题,滑块不能在chrome上工作。如果我手动设置高度,它可以工作,但我有动态内容,因此无法设置固定值 这是我的密码: .directive('slideable', function () { return { restrict:'C', compile: function (element, attr) { // wrap tag var contents = element.

我正在使用angularlideables:

我遇到了一个问题,滑块不能在chrome上工作。如果我手动设置高度,它可以工作,但我有动态内容,因此无法设置固定值

这是我的密码:

 .directive('slideable', function () {
    return {
    restrict:'C',
    compile: function (element, attr) {
        // wrap tag
        var contents = element.html();

        /*
            I need to get the height of the contents variable above so that I can set it within element.html, like so:
            <div class="slideable_content" style="margin:0 !important; padding:0 !important; height: contents.height" >
        */

       // var height = element.html().prop('offsetHeight');

        element.html('<div class="slideable_content" style="margin:0 !important; padding:0 !important;" >' + contents +  '</div>');

        return function postLink(scope, element, attrs) {
            // default properties
            attrs.duration = (!attrs.duration) ? '1s' : attrs.duration;
            attrs.easing = (!attrs.easing) ? 'ease-in-out' : attrs.easing;
            element.css({
                'overflow': 'hidden',
                'height': '0px',
              //  'max-height' : '0';
                //'height': '1500px',
               // 'height': content.scrollHeight,
                'transitionProperty': 'height',
                'transitionDuration': attrs.duration,
                'transitionTimingFunction': attrs.easing
            });
        };
    }
};
})

有什么办法可以让它工作吗?

问题不在于上面的代码。还有另一个指令

出于某些原因,Chrome不喜欢这样做:

var content = target.querySelector('.slideable_content');
    target.style.height = content.scrollHeight + 'px';
相反,这起了作用:

var target = document.querySelector(attrs.slideToggle);
target.style.height = target.scrollHeight + 'px';