Unable to set property ‘Property name’ of undefined or null reference

Browser IE11
Api returning data and is being loaded to custom objects like

 return {
    id: item.Id,
    name: item.Name,

This ‘types’ property is being populated as following by init method:

for (int i=0, i<data.length; i++){
data[i].types = getTypes(); -- this line gives undefined error

Can you please tell what is wrong here?
getTypes() function is returning correct data.

Thanks in advance for providing suggestions.
Sonali Das

Source: AngularJS Questions