I'm trying to figure out how to data bind to arrays in Angular 2 so that changes are reflected. I have a sample todo app with an array property
get tasks(): TaskItem[] {
return this.taskdb.tasks;
}
I would like to make updates efficient so I set changeDetection: ChangeDetectionStrategy.OnPush when the user adds a Task I use array.push to update the underlying data.
add(task: TaskItem) {
this.tasks.push(task);
}
The problem is because the array is the same reference (I don't want to clone and create a new array on every update), and the inputs to the component isn't changing, the UI doesn't update to reflect the change.
Is there a way to do make Angular 2 update the UI on array update but without extraneous checks?