I'm using Angular-cli
. I have:
<div id="show"></div>
and I need to have access this dom element in .ts file
something like document.getElementById('show')
return me null
I'm using Angular-cli
. I have:
<div id="show"></div>
and I need to have access this dom element in .ts file
something like document.getElementById('show')
return me null
try this
<div id="show">
constructor(private elRef:ElementRef) {}
ngAfterViewInit() {
this.elRef.nativeElement.querySelector('#show');
}