There are times when I have to go for DOM event listners
and since
I'm more familiar with querySelector
I can use it with more ease.
But I wonder what does ElementRef
has to offer and which one is better.
ElementRef
and Renderer
provide an abstraction of a part of the DOM API which allows to execute some DOM related actions when no actual browser DOM is available like it is the case when the Angular application is executed by the server or in a WebWorker. Not using this abstraction might prevent your application to utilize server-side-rendering or WebWorkers.
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