【发布时间】:2021-03-31 14:39:50
【问题描述】:
我试图在使用 angular 输入文件上传后立即显示上传的图像。
我试图从打字稿文件中获取 url 以在 html 文件中显示它:
<img src={{url}}>
我有这样的文件:
html:
<input type="file" (change)="onFileChanged($event)" >
ts:
onFileChanged(event) {
this.selectedFile = event.target.files[0]
console.log(this.selectedFile)
}
如何获取图像并立即显示?
【问题讨论】:
-
立即是什么意思?你的代码不工作吗?
标签: angular typescript