我正在编写 AngularJS 指令,在该指令中我想获取 AngularJS 中的选择列表框滚动高度值,但它是未定义的。
请问我怎样才能得到这个值?我可以在 jquery 中获取这个值。
最佳答案
在指令链接函数内:
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;
}
}
});
关于AngularJS如何获取元素的scrollHeight值?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/29342671/