Why native element have 0 size in ngAfterViewInit?
I have embedded component like this:
//my parent component
...
<ion-content>
<inner-component></inner-component>
</ion-content>
...
in inner component:
//html
<div id="map" style="width:500px; height: 500px;" #map ></div>
//ts
...
@ViewChild('map') mapElement: ElementRef;
ngAfterViewInit() {
console.log('height: ' + this.mapElement.nativeElement.offsetHeight);
console.log('width: ' + this.mapElement.nativeElement.offsetWidth);
}
...
Output is always “height: 0 width: 0”
But sometimes: “height: 500 width: 500”
I think that is because the element that i created has not been rendered in the Dom yet?
How i can solve this? Ionic hooks not work with embedded components(