Tuesday, 3 January 2017

Not able to access the array values which are inside of the JSON object from the Lightning Component if 'Enable Lightning LockerService Security update' is enabled

If you add the JSON response which is having the array directly to the Lightning Component Attribute, It is not working.

JSON RESPONSE for response.myData:

[{"attributes":{"type":"TEST"},"pId":"A101","entries":[{"value":"val1"},{"value":"val2"}],"myIndex":0}]

Issue: Not able to access entries and myIndex which are coming after entries (which is Array).

Example:  cmp.set('v.myData', response.myData);

Solution:

Stringify and Parse it like below -
cmp.set('v.myData', JSON.parse(JSON.stringify(response.myData)));

No comments:

Post a Comment