As he said "Jack, the ripper":
Let's go in parts
-
Logo
: This variable does not detect it in change()
because you are not passing it:
Template
<img class="img-position" #logo src="{{img}}">
<input type="button" md-raised-button color="accent" (click)="change(logo)" value="Cambiar"/>
Component
change(logo){
logo.src=data.image;
}
Note: You do not have to access nativeElement
(which in this case would be
undefined
).
-
Data
: Can you tell us how you are defining the object data
?
I have created a test interface and it works without problems:
Component
interface Data{
image: string;
}
data: Data;
ngOnInit(){
this.data= {image: "ruta a mi imagen"};
Template
<img [src]="data.image">
As soon as we see how you build the object, I edit the answer with the possible solution.