Reputation: 12403
I am working on creating a AngularJS site that DOES NOT use JQuery. In a directive, the values that are passed are
EngagementApp.directive('movingAside', function() {
return {
restrict : 'A',
link : function(scope, element, attributes) {
}
}
});
And html looks like:
<div class="aside" moving-aside>...Content...</div>
Doing things like element.clientHeight returns an undefined.
How can get the attributes(height, width, offset, etc) of the element without using JQuery and only AngularJS functions?
Upvotes: 3
Views: 11031
Reputation: 72232
Use element[0].clientHeight | offsetHeight | scrollHeight
element[0]
gives you access to the first DOM element in the JQLite selector collection while clientHeight
is a built in property of the DOM element.
EngagementApp.directive('movingAside', function() {
return {
restrict : 'A',
link : function(scope, element, attributes) {
console.log(element[0].clientHeight);
}
}
});
There are 3 different heights you can get depending on what you're after:
Upvotes: 14