-1

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

alexander.polomodov
  • 5,396
  • 14
  • 39
  • 46
tatamingi
  • 157
  • 4
  • 14

1 Answers1

1

try this

<div id="show">

constructor(private elRef:ElementRef) {}

ngAfterViewInit() {
 this.elRef.nativeElement.querySelector('#show');
}
Fateh Mohamed
  • 20,445
  • 5
  • 43
  • 52