Below is the code snippet that I am currently working on:
<div class="col-sm-4 pl-5">
<img attr.src="{{item?.imagePath}}" required height="200" width="200">
</div>
In my TypeScript file (ts), I have the following function:
editBlog() {
console.log(this.teamForm.value)
const BlogPost = {
"firstName": this.teamForm.value.firstName,
"lastName": this.teamForm.value.lastName,
"description": this.teamForm.value.description,
"designation": this.teamForm.value.designation,
"imagePath": this.teamForm.controls['imagePath'].value,
"status": "status",
"active": true,
"employmentType": {
"id": this.type,
// "employmentTypeName": "Full-Time"
}
}
console.log(BlogPost)
console.log('hftttttt',this.teamForm.value.imagePath)
// console.log(this.id,this.item,this.employmentType)
if(window.confirm('Are you sure you want to update?')){
const jsonData= BlogPost;
if(this.file['name']){}
const formData = new FormData()
formData.append('file', this.file , this.file['name']);
formData.append('jsonData', JSON.stringify(jsonData));
this.team.editTeam(this.id,formData).subscribe((response)=> {
this.router.navigate(['/home/team'])
console.log(response);
});
I am facing an issue where an empty(null) call is made to the API when the image is not updated. Can someone help me figure out how to prevent this and also how to retain the old imagePath if no other values are being updated in the element?