AngularJS如何获取元素scrollHeight值?

jam*_*015 5 angularjs

我正在编写angularJS指令,在这个指令中我想获得angularJS中的选择列表框scrollHeight值,但它是未定义的.

我怎么能得到这个价值?我可以在jquery中获得这个值.

moh*_*ias 7

在你的指令链接功能内:

app.directive("scrollHeightDetector", function() {
     return {
       restrict : "AEC",
       link : function(scope, element, attrs) {
           // here you can use element to get the height

           var height = element[0].scrollHeight;


        }
    }
});
Run Code Online (Sandbox Code Playgroud)