Question: I am dealing with a JavaScript array of objects.
Here's how it looks:
$scope.todos = [
{
face : imagePath,
what: 'Das',
who: 'Sophia',
when: '3:08PM',
notes: " Description 1",
linkForward: "#/tab/listView1"
},
{
face : imagePath,
what: 'Dis',
who: 'Emma',
when: '3:08PM',
notes: " Description 1",
linkForward: "#/tab/listView2"
},
{
face : imagePath,
what: 'Dos',
who: 'Olivia',
when: '3:08PM',
notes: " Description 1",
linkForward: "#/tab/listView3"
}
];
I'm trying to push all these items in a for loop:
This is how I expect the code to look like :
for(var i = 0; i < 3; i++){
$scope.todos[i].face = 'image Path'
$scope.todos[i].what= 'image Path'
$scope.todos[i].who= 'image Path'
$scope.todos[i].when= 'image Path'
$scope.todos[i].linkForward= 'image Path'
}
However, the above approach doesn't seem to work as expected. I want to find a way to create and populate this array dynamically.