Does anyone have a solution for this problem? I recently added an element to my array using the push function, but when I tried to access the element at position 3, it wasn't defined properly
processInput(inputValue: any): void {
this.numOfImages = inputValue.files.length;
for (var i = 0; i < inputValue.files.length; i++) {
let file: File = inputValue.files[i];
let reader: FileReader = new FileReader();
reader.onloadend = (e) => {
if(file.size <= 4000000){
this.imageValues.push(reader.result);
}else{
swal(
'Oops! Image size too large',
'Some images could not be uploaded as they exceed the maximum size of 5 MB :/',
'error'
);
}
}
reader.readAsDataURL(file);
}
this.editImage();
}
editImage(){
console.log(this.imageValues[3]);
}