Reputation: 12005
I use ElementRef in Angular to get DOM elements:
private el: ElementRef;
this.el.nativeElement.children[0];
How to check if element this.el.nativeElement.children[0]
has specific class?
Upvotes: 2
Views: 1785
Reputation: 301
If it is a specific class and you know it, you can use instanceof. Like:
console.log(this.el.nativeElement.children[0] instanceof ClassName);
And it will print true or false, based on the result.
Upvotes: 2