Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

Obtain reference to element angular 4 [duplicate]

I have a component whos template looks like:

..blabla
 <img md-card-image src="..">
..blabla

How do I obtain a reference inside my component.ts so that I could change it's src using angular 4?

like image 770
Jue Debutat Avatar asked May 12 '17 17:05

Jue Debutat


1 Answers

in HTML:

<img #img md-card-image src="..">

in TS:

@ViewChild('img') img: ElementRef;
like image 191
Julia Passynkova Avatar answered Nov 06 '22 21:11

Julia Passynkova