angularprimengprimeng-calendar

Angular: Set default dates for p-calendar


I like to set default Dates for p-calendar PrimeNG component, how do I do that in Angular?


Solution

  • Use ngModel for that.

    <p-calendar [(ngModel)]="value"></p-calendar>
    

    and set your specific date for value property. For instance, if you want to set a date one month before today :

    this.value = new Date();
    this.value.setMonth(this.value.getMonth() - 1);
    

    See Plunker