Date objects that are modified using setDate method arent getting updated in template.
In template:
{{date | date:\'mediumDate\'}}
I think that is the right way, to change the reference of the date variable. From the docs here we have:
The default change detection algorithm looks for differences by comparing bound-property values by reference across change detection runs.
So if the date reference remains the same, nothing will happen. You need a new Date reference and that's why the second version of nextDay()
works.
If you remove the formatting pipe you will see that still only the second version of nextDay()
works.