Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR JAVASCRIPT

File Upload with Angular Material

<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>


::::::::: AND TS ::::::
selectFile(event) {
    this.selectedFiles = event.target.files;
}
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #File #Upload #Angular #Material
ADD COMMENT
Topic
Name
3+3 =