5

I am writing angularJS directive, in this directive I want to get the select list box scrollHeight value in angularJS, but it is undefined.

How can I get this value please? I can get this value in jquery.

0

1 Answer 1

7

Inside your directive link function:

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;


        }
    }
});
Sign up to request clarification or add additional context in comments.

2 Comments

Thanks, it works. why it works use element[0] but got undefined when call element.scrollHeight directly?
jamie2015: element here is a jQuery (or jqLite) object which responds to array indexing. The actual DOM object is the first item in the array.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.