Monday, May 20, 2024
 Popular · Latest · Hot · Upcoming
138
rated 0 times [  139] [ 1]  / answers: 1 / hits: 5301  / 10 Years ago, wed, february 19, 2014, 12:00:00

I'm trying to detect the height of an element that will change depending on data from a database.



I have used .outerHeight successfully before but can't do this on an element that contains data from a ng-repeat.



Is there a way to do this once the data has populated the angular element or is there another method of detecting this?


More From » jquery

 Answers
2

Yes, you need to create an attribute directive and put it on the ng-repeat.



<div ng-repeat=whatever in items outer-height></div>


The directive will have a link function which happens after it has compiled.



app.directive('outerHeight', function(){
return{
restrict:'A',
link: function(scope, element){
//using outerHeight() assumes you have jQuery
//use Asok's method in comments if not using jQuery
console.log(element.outerHeight());
}
};
});


Here's a Plnkr which will log the outerHeight to console: http://plnkr.co/edit/AdGpnzJilW2179Ybuurk?p=preview



Note You will need to use a $watch and get a new height if data changes.


[#47581] Tuesday, February 18, 2014, 10 Years  [reply] [flag answer]
Only authorized users can answer the question. Please sign in first, or register a free account.
theodore

Total Points: 318
Total Questions: 97
Total Answers: 119

Location: Turks and Caicos Islands
Member since Sun, Mar 7, 2021
3 Years ago
;