Could you please provide guidance on obtaining the height
of the content within this particular div
element?
For example, I need to calculate the dynamic height of the content.
https://i.sstatic.net/2kNk3.png
code
.html
<div class="margin-top-47 margin-horizontal-10" #hello>
//content here
</div>
I have attempted several methods without success so far. Any hints or suggestions, please?
.ts
@ViewChild('hello', { static: false }) hello: ElementRef;
ngAfterViewInit(): void {
const xx = this.hello.nativeElement as HTMLElement;
const contentHeight = xx.clientHeight;//it shows 0
//const contentHeight = xx.scrollHeight;//it shows 0 too.
}
console.log
displays the following: