I have angular reactive form by which I am adding data. Adding and updating data working correctly. Below is code
//create form group
this.form = this.formBuilder.group({
name: ['', Validators.required],
categoryImage: [''],
isActive: true
}
When I want to edit this record, I am fetching data from database by Id as below
this.crudService.getById(Category, this.id, 'masters/category')
.pipe(first())
.subscribe(
(cateory) => {
this.data = cateory;
this.form.patchValue(this.data['data'][0])
});
Here this.data['data'][0]
returns object as below
{
id: 5,
name: "cat122222",
image: "uploads/images/categories/node.png",
isActive: 1,
createdBy: 1,
createdAt: "2021-09-05T03:32:35.000Z",
updatedBy: null,
updatedAt: "2021-09-05T03:32:35.000Z"
}
value of categoryImage
form controller is in image
property of object.
Here is my HTML for file controller.
<input
formControlName="categoryImage"
class="form-control file-upload category-control"
type="file"
value="image"
(change)="getFile($event)"
/>
but when I open Edit form, I want to show File name in File Control. How can I show file name there?
Right now. I can show image file but I want that image name in file controller as well, so user don't need to select file again if no change in file.