How can I dynamically adjust the date in an input box by using buttons to increment and decrement it? Below is the code snippet:
prev() {
let diff = 1; //1 to increment and -1 to decrement
this.date.setDate(this.date.getDate() - diff);
console.log(this.date);
}
next() {
let diff = 1; // 1 to increment and -1 to decrement
this.date.setDate(this.date.getDate() + diff);
console.log(this.date);
}
In the HTML file:
<input type='text' id='datepicker' name='datepicker' class="form-control"
[ngModel]="{{date | dd-MM-yyyy}}">
<button (click)="prev()"></button>
<button (click)="next()"></button>