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

142
Visualizações
ionic 6 ion-datetime restricting dates to just max 2 dates

I am using ionic 6 for ion-datetime with property multiple="true". I want to make sure that user cannot select more than 2 dates. and if user selects the 3rd date then i want to remove the oldest date automatically rather throwing a validation error. The code is like below:

  <ion-datetime presentation="date" multiple="true" preferWheel="false" [(ngModel)]="packageEstimatedDated" (ionChange)="validateDates()"></ion-datetime>

for .ts

packageEstimatedDated
async validateDates(){
    console.log("selected dates length:", this.packageEstimatedDated.length)
    
    if(this.packageEstimatedDated.length === 3){
      console.log("after remove extra date", this.packageEstimatedDated)
      this.packageEstimatedDated.splice(0,1)
      console.log("after removed", this.packageEstimatedDated)
    }
  }

The problem is that even the splice is removing the element but it still not really. Here is the output i see when i select 4 dates one by one:

selected dates length: 1
new-order.page.ts:61 selected dates length: 2
new-order.page.ts:61 selected dates length: 3
new-order.page.ts:72 after remove extra date (3) ['2022-08-10', '2022-08-18', '2022-08-23']
new-order.page.ts:74 after removed (2) ['2022-08-18', '2022-08-23']
new-order.page.ts:61 selected dates length: 4
about 4 years ago · Juan Pablo Isaza
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