Having the similar requirement, where wanted to make transitable native browser labels "Choose file" and "No file chosen". I achieved by writing below code.
Just need to create an input field applying style as display: none, and some element id, which need to be used in label tag as for="elementId"
In template (.html) file
<span fxLayout="column">
<span fxLayout="row">
<label for="file" class="btn btn-primary btn-block btn-outlined">{{"commonKeysText.chooseFile"
| translate}}</label>
<input placeholder="{{translatedPlaceholderText}}" readonly>
</span>
<input type="file" style=" width: 100%; display: none;" id="file" name="file"
(change)="onFileSelect($event)" />
</span>
In component (.ts) file
fileupload: FormGroup;
translatedPlaceholderText = this.translateService.instant('commonKeysText.noFileChosen');
this.fileupload = this.fb.group({
file: ['', [Validators.required]],
});
onFileSelect(event) {
let file = event.target.files[0];
if (event.target.files.length > 0) {
this.fileupload.get('file').setValue(file);
} else {
file = null;
this.fileupload.get('file').setValue(file);
}
this.translatedPlaceholderText= this.fileupload.get('file').value.name;
}
onResetFileSelection() {
(<HTMLInputElement>document.getElementById('file')).value = '';
this.translatedPlaceholderText= this.translateService.instant('commonKeysText.noFileChosen');
}