Hi all! I’m currently working on a simple Firebase/Ionic to do list app for an assignment. I’m quite new to Ionic and still figuring things out. I want to add an ngClass to each task in the list so that when the task is checked off, the task name gets striked through. The way I want to go about doing this is by assigning a status of ‘pending’ to each newly created task. Then, when the checkbox is ticked, the status is updated to ‘done’ and the ngClass changes the css. This is what I have so far but I’m getting the error: Cannot read property ‘set’ of undefined.
<ion-checkbox item-right (ionChange)="doneTask(task.key, task.status)"></ion-checkbox>
<ion-label>
<h2 [ngClass]="{'done': task.status !== 'pending'}">{{task.taskname}}</h2>
And in my typescript I have the following:
private taskListRef = this.db.list<Task>
('todoAppdb');
task = {
id:'',
status:'done',
listid:1
} as Task
In the constructor I have:
this.task.id = this.navParams.get('key'),
this.task.status = this.navParams.get('status')
And my function is:
doneTask(id, status){
this.taskListRef.update(this.task.id, {
status = this.task.status
})
}
I’m not really sure what’s causing the error. Any help would be appreciated, thank you!