0

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

apiData.map(function(item){
 return {
    id: item.Id,
    name: item.Name,
    types:{}
});

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

2 Answers2

0

You can try like this

for (int i=0, i<data.length; i++){
  var datatype = getTypes(data[i].types);
}
Zahidul
  • 76
  • 5
0

First, I see that you have some syntax errors here:

apiData.map(function(item){
 return {
    id: item.Id,
    name: item.Name,
    types:{}
 } //missing a curly braces here
});

syntax again:

for (let i=0; i<data.length; i++){ //not int, ";" not ","
  data[i].types = getTypes();
}

Second, .map will not change the original array but return a new array, make sure that you have assigned the new returned array to data

It should look like this

var data = apiData.map(function(item){
 return {
    id: item.Id,
    name: item.Name,
    types:{}
  }
});
for (let i=0; i<data.length; i++){ 
   data[i].types = getTypes(); 
}
Dharman
  • 30,962
  • 25
  • 85
  • 135
Vo Minh Khanh
  • 89
  • 1
  • 3