I am trying to retrieve the height of an image after it finishes loading. Despite my attempts, the offsetHeight property returns 0 and the other methods do not return any values. I can confirm that the elements are loaded when querying their heights because I successfully set their widths using getElementById and setAttribute right before checking their heights.
* {
margin: 0;
padding: 0;
border: 0;
}
.gallery {
display: flex;
flex-direction: row;
flex-wrap: wrap;
}
.gallery img {
width: 100%;
display: block;
}
The image with the id "6" does exist and has been rendered at the time of these TypeScript calls.
My hypothesis behind trying to get the bottom position was based on the idea that if I could determine the top and bottom coordinates of the image, I could calculate its height without directly retrieving it.
console.log(document.getElementById("6").offsetHeight.toString());
console.log(document.getElementById("6").offsetHeight.valueOf());
console.log(document.getElementById("6").style.height);
console.log(document.getElementById("6").style.bottom);
console.log(document.getElementById("6").style.borderBottom);
HTML
<div id={{i}} *ngFor="let image of images; let i = index;">
<img class="img-responsive" src={{image.src}} alt="" (click)="clicked()">
</div>