0

dragAndUpload.ts

export class DragAndUploadComponent implements OnInit {
  @Input() filesData: any;
  ngOnChanges(changes: SimpleChanges): void {
    console.log(changes.filesData.currentValue);
    console.log(changes.filesData.currentValue.files);
  }
}

in console: Object { } //when this object expand its shows like below

Object{
 "files": {
    "image": [
      "image_link"
    ],
    "video": [
      "video_link"
    ]
  }
 }
}

and the console of the (changes.filesData.currentValue.files) is undefined

HOW CAN I SOLVE THIS ISSUE

Thanks in Advance

Chaka15
  • 1,105
  • 1
  • 8
  • 24
  • Please create a exmaple code using stackbltz to troubleshoot more. – Vimal Patel Dec 29 '21 at 07:03
  • I suspect that the event was triggered first on initialization, but the data you were seeing is pass by reference can you try `JSON.stringify(changes.filesData.currentValue)` to detach it from being reference and see if it still the same on the value you posted. – Forbidden Dec 29 '21 at 07:09
  • ngOnchanges only triggers when there is a different reference. If you pass the same object, but with some modification no change will be triggered. Make a copy with spread operator and check again. – dmance Dec 29 '21 at 07:53

0 Answers0