Date objects that are modified using the setDate method are updated in the template.
In the template:
<p>{{date | date:'mediumDate'}}</p>
In component:
nextDay(){ this.date.setDate(this.date.getDate()+1); }
But when I call the nextDay function, the template is not updated with the new value.
The only way I could work with change detection was as follows:
nextDay(){ var tomorrow = new Date(); tomorrow.setDate(this.date.getDate()+1); this.date = tomorrow; }
Is there a better way to accomplish this same task?
nsbm
source share