Ensure that your HTML file includes the following content:
<input type="file" id="ifile" class="form-control" #fileInput (change)="preUpload($event)" />
<label class="custome-file-label" *ngIf=!isFileChosen>Choose file</label>
<label class="custome-file-label" *ngIf=isFileChosen>{{fileName}}</label>
Include the following method in your component.ts file:
isFileChosen:boolean = false;
fileName: string = '';
preUpload(event){
let file = event.target.files[0];
if (event.target.files.length > 0){
this.isFileChosen = true;
}
this.fileName = file.name;
}
By uploading a file, the count will be greater than 0 allowing you to see your name instead of the 'Choose File' label.
For a live example, visit this link