var selectCheckbox = [];
for (i = 0; i <= escConfigForm.chapters.size; i++) {
if (escConfigForm.chapters['i']) {
selectCheckbox.push({
id: $scope.chapters['i'].id,
name: $scope.chapters['i'].name
});
}
console.log(selectedCheckbox);
In this script, I am populating an array with objects obtained from $scope.chapters
. Here is a sample of what these objects look like:
[{"name":"Chapter 9: Negative Messages","id":"832115"},{"name":"Chapter 13: Proposals, Business Plans, and Formal Business Reports","id":"832124"}].
At the same time, I am comparing them to the escConfigForm.chapters
, which presents as an object with values like (0:true, 1:true, 2:true);
The issue arises when trying to determine the size or length of escConfigForm.chapters
, as accessing escConfigForm.chapters.size
or escConfigForm.chapters.length
returns undefined
.