can anybody tell how to get document object angular. I have tried with ElementRef. It is not working
let elements = this.elem.nativeElement.querySelectorAll('.classImLookingFor');
Can anybody suggest how to get querySelectorAll in component in angular?
Thanks
import { Component, Inject, ... } from '@angular/core';
import { DOCUMENT } from '@angular/common';
export class MyComponent {
// ...
constructor(@Inject(DOCUMENT) private document: Document) {}
myMethod() {
this.document.<whatever ...>
// ...
}
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With