Today, I encountered a problem with the following function:
uploadPhoto() {
var nativeElement: HTMLInputElement = this.fileInput.nativeElement;
this.photoService.upload(this.vehicleId, nativeElement.files[0])
.subscribe(x => console.log(x));
}
When accessing nativeElement.files[0], TypeScript is generating an error stating "Object is possibly 'null'". Has anyone else faced and solved this issue before?
I attempted to declare nativeElement as a null value, but unfortunately was unsuccessful in resolving the error.
Thank you for any assistance and input provided.