- Forums
- AngularJS
- Javascript Angularjs Getting A Bunch Of Null In An Object Array
this is how i was able to solve an object or an array i had with a bunch of null values. [4614], Last Updated: Mon Jun 24, 2024
webune
Tue Nov 22, 2016
0 Comments
463 Visits
these are some notes i created for a problem i had when i would push some data into an object in my javascript code, i was using angularjs, the object or the array i should say looked like this:
factoryQuestion
[
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
null,
..... 1000 more..
{
"Question": "Do you currently have a website? ",
"inputType": "0",
"FlagForReview": false,
"AnswerIds": "",
"options": {
"11": {
"text": "Yes"
},
"12": {
"text": "No"
}
}
}
]
the jascript was like this:
$scope.factoryQuestion = new Array();
then i would put a new element into the array: like this;
$scope.factoryQuestion[i]=$scope.webune_question[i];
to solve this, all i had to change was:
$scope.factoryQuestion = new Array();
to
$scope.factoryQuestion = {};
so basically, you need to change the variable from an array to an object;
done