I have a task list stored in an object items
, I want to parse this list so that everything with open status is stored in the openTasks
variable and everything is with status completed is stored in completedTasks
.
I even scribbled something but it did not work. See:
export class AllTasksPage {
openTasks;
completedTasks;
items = [
{'title': 'Entregar relatório', 'note': '', 'image': '', 'status': 'aberta'},
{'title': 'Fazer compras', 'note': '', 'image': '', 'status': 'aberta'},
{'title': 'Concluir trabalho da faculdade', 'note': '', 'image': '', 'status': 'concluida'},
{'title': 'Ligar para cliente', 'note': '', 'image': '', 'status': 'concluida'},
{'title': 'Revisar trabalho', 'note': '', 'image': '', 'status': 'aberta'},
{'title': 'Falar com chefe', 'note': '', 'image': '', 'status': 'concluida'},
{'title': 'Estudar apra prova', 'note': '', 'image': '', 'status': 'aberta'},
{'title': 'Buscar roupa na lavanderia', 'note': '', 'image': '', 'status': 'aberta'},
{'title': 'Limpar a casa', 'note': '', 'image': '', 'status': 'aberta'},
{'title': 'Estudar para apresentação', 'note': '', 'image': '', 'status': 'aberta'},
{'title': 'Assistir filme xpto', 'note': '', 'image': '', 'status': 'aberta'},
{'title': 'Colocar a roupa para lavar', 'note': '', 'image': '', 'status': 'aberta'}
];
constructor(public navCtrl: NavController, public alertCtrl: AlertController) {
for (let item of this.items) {
if (item.status == 'aberta') {
this.openTasks.concat(item);
}
}
}
In short, I want openTasks
and comletedTasks
to have the same structure as items
, but data will change based on task status.