[英]upload file with angular 5 and material
I'm working with Angular 5 and material library .我正在使用 Angular 5 和material library 。 I need to upload a file, but in the documentation, I didn't find an explanation to accomplish this task.
我需要上传一个文件,但在文档中,我没有找到完成此任务的解释。
Is anybody that have the same need that can suggest me a good tutorial or documentation?有没有人有同样的需求可以给我推荐一个好的教程或文档?
Tnx Tnx
There is a nice library that handles this requirement that also follows Marerial Design.有一个很好的库可以处理这个也遵循 Marerial Design 的需求。 See attached link:
见附件链接:
I had the same problem and I personalized a component with Angular Material without external libs and feedback with the name of the chosen file into field:我遇到了同样的问题,我使用 Angular Material 个性化了一个组件,没有外部库,并将所选文件的名称反馈到字段中:
HTML HTML
<mat-form-field class="columns">
<mat-label *ngIf="selectedFiles; else newFile">{{selectedFiles.item(0).name}}</mat-label>
<ng-template #newFile>
<mat-label>Choose file</mat-label>
</ng-template>
<input matInput disabled>
<button mat-icon-button matSuffix (click)="fileInput.click()">
<mat-icon>attach_file</mat-icon>
</button>
<input hidden (change)="selectFile($event)" #fileInput type="file" id="file">
</mat-form-field>
TS TS
selectFile(event) {
this.selectedFiles = event.target.files;
}
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.