![](/img/trans.png)
[英]How to change the label text in Angular Material File Upload
[英]upload file with angular 5 and material
我正在使用 Angular 5 和material library 。 我需要上傳一個文件,但在文檔中,我沒有找到完成此任務的解釋。
有沒有人有同樣的需求可以給我推薦一個好的教程或文檔?
Tnx
有一個很好的庫可以處理這個也遵循 Marerial Design 的需求。 見附件鏈接:
我遇到了同樣的問題,我使用 Angular Material 個性化了一個組件,沒有外部庫,並將所選文件的名稱反饋到字段中:
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
selectFile(event) {
this.selectedFiles = event.target.files;
}
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.