You can use @ViewChild with a div by adding a TemplateRef.
Template
<div id ="myId" #myId>
Component
import { Component, ViewChild, ElementRef, AfterViewInit } from '@angular/core';
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css']
})
export class AppComponent implements AfterViewInit {
@ViewChild('myId') myId: ElementRef;
constructor() {
}
ngAfterViewInit() {
console.log(this.myId.nativeElement);
}
}
This blog post by Kara Erickson is a really good read for getting familiar with the Angular approach to doing things like this.