I like to set default Dates for p-calendar PrimeNG component, how do I do that in Angular?
Asked
Active
Viewed 5,426 times
1 Answers
2
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

Antikhippe
- 6,316
- 2
- 28
- 43
-
This works thanks, but I want to set date to 30 days ago, how do I do that, given that the current date is this? – kenadet Mar 12 '18 at 19:22
-
@Kenadet you're welcome. Please approve this answer if it helped you – Antikhippe Mar 13 '18 at 05:46
-
@Antikhippe, i want to do the same but in my case i've to show a range in p-calendar. Can you please help. – Tanzeel May 18 '23 at 06:54