Empresas
Empregos
  • Sobre nós
  • Soluções
    • Publicação de vagas
      Publique sua vaga e receba candidatos qualificados em 48h.
    • Avaliações de candidatos
      Mais de 500 testes técnicos e psicológicos, mais anti-fraude.
    • Headhunting
      Busca executiva personalizada do início ao fim.
    • Folha de Pagamento + EOR
      Dispersão de folha e EOR em mais de 15 países da LATAM.
  • Preços
  • Empregos

0

152
Visualizações
How to add one day to Bootstrap DatePicker when one date is pick in Angular

Good day Developer, I have two input boostrap datepicker for a user to select and I want if the first date field is selected, the next date field should start from a day plus the start date initially selected on the first date field. this is my first Input field:

<input
  (blur)="setMinDate($event)"
  id="StartTime"
  type="text"
  name="StartTime"
  class="form-control"
  bsDatepicker
  datePickerLuxonModifier
  [(date)]="userFirstInput.startTime"
  [(ngModel)]="userFirstInput.startTime"
  [maxDate]="userFirstInput.endTime"
  [minDate]="startdate"
  [bsConfig]="{ adaptivePosition: true }"
  required
/>

this is the second input field:

<input
  id="EndTime"
  type="text"
  name="EndTime"
  class="form-control"
  bsDatepicker
  datePickerLuxonModifier
  [(date)]="userSecondInput.endTime"
  [(ngModel)]="userSecondInput.endTime"
  [minDate]="minPickDate"
  [bsConfig]="{ adaptivePosition: true }"
  required
/>

the function am applying on first date input in order to store the get the date pick on first input date and add a day to it, which will be use as [minDate] on the second input date field:

minPickDate: DateTime;
    
setMinDate(event){
  this.minPickDate = this.userFirstInput.startTime.plus({days:1});
}

But is not working, I try using ngModelChange and Change event but it still didn't work out. Please I need help.

about 4 years ago · Juan Pablo Isaza
1 Respostas
Responde à pergunta

0

Try to below using bsValueChange, I hope it work for you

<input
  (bsValueChange)="setMinDate($event)"
  id="StartTime"
  type="text"
  name="StartTime"
  class="form-control"
  bsDatepicker
  datePickerLuxonModifier
  [(date)]="userFirstInput.startTime"
  [(ngModel)]="userFirstInput.startTime"
  [maxDate]="userFirstInput.endTime"
  [minDate]="startdate"
  [bsConfig]="{ adaptivePosition: true }"
  (bsValueChange)= "setMinDate($event)"
  required />

ts minPickDate : date;

 setMinDate(value){
    var nextDay = new Date(value);
    nextDay.setDate(nextDay.getDate() + 1);
    this.minPickDate = nextDay;
 }
about 4 years ago · Juan Pablo Isaza Relatório
Responde à pergunta
Encontrar trabalhos remotos

Descubra a nova forma de encontrar um emprego!

melhores empregos
Principais categorias de trabalho
Empresas
Postar vaga Preços Comercial
Jurídico
Termos e Condições Política de privacidade
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Recomende algumas ofertas para mim
Preciso de ajuda