[英]how to change image dynamically in angular 4
export class AppComponent {
title = 'app';
bttnclick(){
var a;
a=(<HTMLInputElement>document.getElementById('browse1')).value
console.log(a); //contains the name of image
(<HTMLInputElement>document.getElementById('image2')).value=a;
}
}
i am beginner in this field, i want to change the image source by changing value in the browse box in angular. 我是该领域的初学者,我想通过更改角度浏览框中的值来更改图像源。
The simplest way to connect two siblings is using a template variable (like #input
here: 连接两个兄弟姐妹的最简单方法是使用模板变量(如#input
此处:
<input #input>
<img src="/my/path/{{input.value}}">
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.