Cannot set properties of undefined (setting base64)

Viewed 19

I have an array data im trying to access that array data and assign a value but there is an issue ill share my model and code below

this.downloadPDF(true);
this.hubxTestApprovedForPatient[0].base64 = this.fileList --error occurs here--
let dic = [];

And below code is my model

export class SaveHubxTestApprovedForPatientModel{
    id : number;
    patientId : number;
    hubxCategoryId : string;
    isTestApproved : boolean;
    notes : string;
    base64: any;
}

this is how i declare my model in my component class

 hubxTestApprovedForPatient : Array<SaveHubxTestApprovedForPatientModel>=[];
1 Answers

Your array is empty. ty to do this

hubxTestApprovedForPatient.push(new SaveHubxTestApprovedForPatientModel());

then you can

this.hubxTestApprovedForPatient[0].base64 = this.fileList;
Related