Answer the question
In order to leave comments, you need to log in
Cannot read property 'nativeElement' in ngAfterContentInit, how to get reference to DOM element?
The code:
@ViewChild('container', { static: true }) container: ElementRef;
ngAfterContentInit() {
try {
this.mapLoaded = this.mapLibrary.ready;
} catch (e) {
console.error(e);
}
}
TypeError: Cannot read property 'nativeElement' of undefined
<app-map-wrapper>
<div id="map" #container></div>
</app-map-wrapper>
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question