I want to remove a specific object from a list. The object model looks like this:
export class Task {
taskId: number;
projectId: Project;
userId: User;
state: string;
description: string;
}
I created a list of Task objects and I want to delete a Task that has a specific taskId.
moveTaskInProgress(task: Task) {
console.log('The task is in progress...');
task.state = 'IN_PROGRESS';
this.taskService.updateTask(task).subscribe((nbOfUpdates) => {
console.log('Number of updates: ' + JSON.stringify(nbOfUpdates));
this.removeItemFromAListOfTasks(task, this.openTasks);
console.log('List of task task: ' + JSON.stringify(this.openTasks));
});
}
removeItemFromAListOfTasks(task: Task, listOfTasks: Task[]) {
let filteredList: Task[];
filteredList = listOfTasks.filter(item => item.taskId !== task.taskId);
}
I have a method that receive a task, call a method that updates some properties, and after that i want to delete the task from the list.
But it seems that nothing happen. Could you, please, help me with this?
filteredListwill contain all tasks that have a taskId different from whatevertask.taskIdis. What's your problem?