I have been working in angular( version 5.2 ) for a couple of months now and feel as though I must be missing something fairly obvious. My problem is that I need to perform manipulation to my data between the view and the model.
For example I am building a simplified app that interacts with Microsoft project. The end user should only have to enter a start and end date for each task. Depending on a few other factors that exist within my component it may update the models start/end date directly( +- extra days) or alter another variable within that task. So using
<input type="date" [(task.startDate)] />
isn't really appropriate. My solution to this is was to use something like
<input type="date" (change)="processTheDate($event.value, task)" [value]="task.startDate" >
private processTheDate(value: Date, task: Task){
//do some proccessing
//set the value
task.startDate = value;
}
From what I have read online this is not the preferred solution
My questions is actually two fold.
1. What is wrong with usurping angular's data binding such as in my example?
2. What is a better alternative?