我有一个项目,我需要通过按钮将文档添加到 API
但现在我只需要按钮打开文件选择器,让我选择文件并返回它的名称。
我已将此按钮分配给该事件。
那么有人可以帮我打开文件查找器的代码吗?我是 Angular 的初学者。
按钮:
<button (click)="myEvent($event)">Add Document</button>
事件:
myEvent (event) {
console.log(event); }
Run Code Online (Sandbox Code Playgroud)
预先感谢,大卫。
你需要
<input type="file" multiple="multiple" (change)="change($event)">
Run Code Online (Sandbox Code Playgroud)
在你的 .ts 文件中你可以得到:
change(event:any) {
console.log(event.target.files);
}
Run Code Online (Sandbox Code Playgroud)
| 归档时间: |
|
| 查看次数: |
4368 次 |
| 最近记录: |