I have a problem of getting a ngRepeat table's height when page loaded
I'm trying to get the height when event $viewContentLoaded fires, but the table's height equals the height of the title bar of the table. My table looks like this:
How to get the correct height of the table? Thanks a lot.
Here is my code:
$scope.$on('$viewContentLoaded', function(){
var elem = angular.element(document.getElementById('ng-repeat-table-test'));
console.log(elem.height());
});
The actual table height measured by Chrome Developer tool is 234px. However, the above code print out 100px, which is the height of the title bar.
More Code:
code for rendering the table:
<table id="ng-repeat-table-test">
<tr id="title">
<td>Car Types</td>
</tr>
<tr class="row" ng-repeat="car in cars">
<td>{{car.name}}</td>
</tr>
</table>
CSS:
table{
margin-left: auto;
margin-right: auto;
margin-top: 10px;
}
tr#title{
height: 100px;
background-color: #ccc;
}
tr.row{
padding-top: 10px;
border-top: 1px solid #ccc;
}
tr.row:first-child{
border-top: none;
}
tr.row td{
padding-top: 10px;
height: 56px;
vertical-align: top;
}
Small chunk of code on jsfiddle