[Solved] ERROR TypeError: Cannot set property ‘abc’ of undefined Angular2

[ad_1]

this in the reader.onload is not the object’s context. So it haven’t any variable with name jsondata. You can use arrow function to preserve your context to the object.

reader.onload = (eve:any) => {
    this.jsondata['json_def'] = JSON.parse(eve.target.result);

    console.log(this.json_def);
}

1

[ad_2]

solved ERROR TypeError: Cannot set property ‘abc’ of undefined Angular2