Here is some code snippet from different files:
<div #sampleComponent class="cdt-sample-component"
[ngStyle]="{'height': (view_height) + 'px'}" >
<app-component></app-component>
</div>
css file:
.cdt-sample-component {
display: flex;
flex: 1;
height: calc(100% / 3);
}
}
ts file:
constructor(private renderer: Renderer2) {
}
ngAfterViewInit() {
logger.info("NativeElement height " + this.renderer.selectRootElement(this.metricsComponent['nativeElement']).getAttribute('height'));
}
The log printed in the ts file shows that the "height" attribute returns null. How can I retrieve the value of the height attribute defined in the CSS file for the "cdt-sample-component" div element?
This issue arises while using Angular 7. Any insight on how to access the height attribute value defined in the CSS file from the ts file would be greatly appreciated.