After using Angular (version 5.2) for a few months, I've come across a situation where I feel like I might be overlooking an obvious solution. The issue I'm facing involves manipulating data between the view and the model.
For instance, in my project where I am working on a simplified app that interacts with Microsoft Project, users are supposed to input start and end dates for each task. Based on certain conditions within my component, these dates may need to be adjusted directly or affect another variable in the task. Therefore, using something like
<input type="date" [(task.startDate)] />
doesn't seem ideal. My workaround for this has been utilizing code like
<input type="date" (change)="processTheDate($event.value, task)" [value]="task.startDate" >
private processTheDate(value: Date, task: Task){
//do some processing
//set the value
task.startDate = value;
}
However, according to some discussions I've read online, this might not be the best approach (source).
My question is two-fold:
1. What are the drawbacks of bypassing Angular's data binding in the manner shown above?
2. Can you suggest a more effective alternative?