Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Primeng calendar not updating the value of date in ngModel #14576

Closed
jithinpathrose opened this issue Jan 17, 2024 · 1 comment
Closed

Primeng calendar not updating the value of date in ngModel #14576

jithinpathrose opened this issue Jan 17, 2024 · 1 comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible

Comments

@jithinpathrose
Copy link

Describe the bug

I am trying to use an p-calendar with icon like this



                    <p-calendar 
                           [showOnFocus]="false"
                           [locale]="sw"
                           dateFormat="yy-mm-dd"
                           [style]="{'width': '120px'}"
                           [showIcon]="true"
                           [(ngModel)]="abc.efg.fromDate"
                           [check]="checkDate()"
   
                           [keepMessage]="true"
                           [keepInvalid]="true"
                           (onSelect)="dateOnSelect($event)"
                           alwaysShow></p-calendar>

and the implementation of checkDate() in the app component looks like this

  checkDate(): ValidatorFn {
       return (control: AbstractControl): { [key: string]: any } => {
         console.log('date from : ', this.abc.efg.fromDate);
         // other implementation
                 }
         }

The issue I am facing is that, whenever I pick a date (by clicking the icon), I get call in the checkDate() and the value of this.abc.efg.fromDate is not the value I picked from the date picker, in fact it is the previous value in the date field.

How can I solve this ? assuming that the ngModel should have the updated value even if I am using the icon.

Won't the ngModel get updated as soon the date is picked from the date picker icon ?

PS: this.abc.efg.fromDate is a date field.

Environment

Angular UI with Primeng calendar

Reproducer

No response

Angular version

14.2.13

PrimeNG version

9.1.12

Build / Runtime

Angular CLI App

Language

TypeScript

Node version (for AoT issues node --version)

20.10.0

Browser(s)

No response

Steps to reproduce the behavior

No response

Expected behavior

No response

@jithinpathrose jithinpathrose added the Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible label Jan 17, 2024
@jithinpathrose jithinpathrose changed the title Primeng calendar not updating the value of date in ngModelComponent: Title Primeng calendar not updating the value of date in ngModel Jan 17, 2024
@mehmetcetin01140
Copy link
Contributor

Hi,

So sorry for the delayed response! Improvements have been made to many components recently, both in terms of performance and enhancement. Therefore, this improvement may have been developed in another issue ticket without realizing it. You can check this in the documentation. If there is no improvement on this, can you open a new issue so we can include it in our roadmap?

Thanks a lot for your understanding!
Best Regards,

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Status: Needs Triage Issue will be reviewed by Core Team and a relevant label will be added as soon as possible
Projects
None yet
Development

No branches or pull requests

2 participants