I am trying to display the results from an array into the html template. I need to display the tasks objects. Currently I can successfully console log the result but when I try to display it I get a blank ion-list. I am retrieving the array from Ionic storage.
[
{
"projects": {
"projectname": "test",
"dateadded": "09 April 2018, 6:29AM",
"location": "us",
"tasks": {
"0": {
"taskname": "test",
"taskdescription": "test",
"taskdealer": "test",
"tasksupplier": "Technical",
"taskdeadline": "2018-04-08"
},
"1": {
"taskname": "test",
"taskdescription": "test",
"taskdealer": "test",
"tasksupplier": "Technical",
"taskdeadline": "2018-04-08"
}
}
}
}
]
My attempt
this.storage.get('projectsStore').then(data => {
for (var i = 0; i < data.length; i++) {
console.log(data[i].projects.tasks);
this.tasks = [data[i].projects.tasks];
}
})
<ion-list>
<button ion-item no-padding *ngFor="let item of tasks">
<h2>{{item.taskname}}</h2>
<p>{{item.taskdeadline}}</p>
</button>
</ion-list>
{ "0":{ "taskname":"test", "taskdescription":"test", "taskdealer":"test", "tasksupplier":"Technical", "taskdeadline":"2018-04-08" }, "1":{ "taskname":"test", "taskdescription":"test", "taskdealer":"test", "tasksupplier":"Technical", "taskdeadline":"2018-04-08" } }