When I upload a picture as a data record, the image is sent to a server folder and its name is stored in the database.
For this editing form, I retrieve the file name from the server and need to populate <input type="file">
in Angular 6 using reactive forms.
Here's my TypeScript code:
ngOnInit() {
this.EditForm=this.fb.group({
imageName:['',Validators.compose([Validators.required])]
})
this.SetForm(this.dat)
}
SetForm(dt:data){
this.EditForm.setValue({imageName:[dt.imageName]});
}
In the HTML:
<form [formGroup]="EditForm">
<input type="file" #file formControlName="imageName">
</form>
If you want to see the actual code, here's the link: stackblitz
I've been struggling with this issue for three days now. Please review my code and suggest any changes that could help solve this problem.