I am trying to update a date dynamically from a user clicking a forward or backward button, but can't seem to figure out how to make the data change from the view.
The variable date changes but not from the browser.
< July 31, 2017 >
EDIT: I had originally put my methods inside the constructor (I don't have it that way in my code, but rather me mistyping it in the question here)
App Component
export class AppComponent {
date: Date;
constructor () {
this.date = new Date();
}
dateForward() {
this.date.setDate(this.date.getDate() + 1);
}
dateBack() {
this.date.setDate(this.date.getDate() - 1);
}
}
HTML Template
<i (click)="dateBack()" class="fa fa-chevron-left" ></i>
<a>{{date | date:'MMM d, y'}}</a>
<i (click)="dateForward()" class="fa fa-chevron-right"></i>