Is it possible to access DOM elements from an Angular2 template ? If not, is there a way to achieve that ? I want to be able to access some DOM element in my template and modify it after the HTML load (load event).
Asked
Active
Viewed 142 times
1
-
2Possible duplicate of [angular 2 / typescript : get hold of an element in the template](http://stackoverflow.com/questions/32693061/angular-2-typescript-get-hold-of-an-element-in-the-template) – BobV Dec 17 '15 at 22:02
-
My main goal here is to be able to execute javascript code that accesses the DOM from within a template. Is there a way to do that ? – Attilah Dec 18 '15 at 01:08
-
Yes, inject ElementRef in your constructor and use the nativeElement property. See the second answer in link above. – BobV Dec 18 '15 at 13:23