Reputation: 1670
I cannot get the height of an rendered element. It returns null. I need the element to check its height it self without user interaction.
HTML
<span ng-if="contentHeight($element)" ></span>
JS
$scope.contentHeight = function(element){
console.log($(element).height());
return true;
};
Upvotes: 0
Views: 135
Reputation: 79
It might work better for you if you use a directive here because it passes the element into the directive itself.
HTML
<span class="directive"></span>
JS
app.directive('directive', function(){
return{
restrict: 'C',
link: function(scope, element, attrs){
console.log($(element).height());
}
}
});
I'm not sure exactly what you're trying to do, but that might solve your problem :)
Edit: added documentation! https://docs.angularjs.org/guide/directive
Upvotes: 2