i am trying to set endDate inputs minDate to be startDates 1 day value. what am i doing wrong?
.ts
this.minendDate.setDate(this.minendDate.getDate() 1);
this.maxendDate.setDate(this.maxendDate.getDate() 365);
this.form.get('startDate').valueChanges.subscribe((value) => {
console.log(value);
this.minendDate.setDate(value 1);
});
.html
<input formControlName="startDate"
[minDate]="minstartDate"
[maxDate]="maxstartDate"
bsDatepicker
#dp="bsDatepicker"
autocomplete="off"
[bsConfig]="{ adaptivePosition: true }" />
<input
formControlName="endDate"
[minDate]="minendDate"
[maxDate]="maxendDate"
bsDatepicker
#dp="bsDatepicker"
autocomplete="off"
[bsConfig]="{ adaptivePosition: true }" />
CodePudding user response:
you can set using bsValueChange
. try below way i hope it work for you.
this.minendDate.setDate(this.minendDate.getDate() 1);
this.maxendDate.setDate(this.maxendDate.getDate() 365);
changeStartDate(value){
var nextDay = new Date(value);
nextDay.setDate(nextDay.getDate() 1);
this.minendDate = nextDay;
}
html
<input formControlName="startDate"
[minDate]="minstartDate"
[maxDate]="maxstartDate"
bsDatepicker
#dp="bsDatepicker"
autocomplete="off"
[bsConfig]="{ adaptivePosition: true }"
(bsValueChange)= "changeStartDate($event)"
/>
<input
formControlName="endDate"
[minDate]="minendDate"
[maxDate]="maxendDate"
bsDatepicker
#dp="bsDatepicker"
autocomplete="off"
[bsConfig]="{ adaptivePosition: true }" />