Does anybody know how to get hold of an element defined in a component template? Polymer makes it really easy with the $ and $$.
$
$$
I was just
import the ViewChild decorator from @angular/core, like so:
ViewChild
@angular/core
HTML Code:
... ...
TS Code:
import { ViewChild } from '@angular/core'; class TemplateFormComponent { @ViewChild('f') myForm: any; . . . }
now you can use 'myForm' object to access any element within it in the class.
Source