Mohammed Doulfakar
Mohammed Doulfakar

Reputation: 128

Binding an array of dates with PrimeNg calendar is not working

I am using a PrimeNg calendar to select multiple dates, and i bound the component to an array of dates using [(ngModel)]. When i select a date it's automatically pushed to the array but when i deselect a date it's always there.

Here is the calendar template :

<p-calendar name="DupDates" [(ngModel)]="DupDates" [dateFormat]="dateFormat" 
           [monthNavigator]="monthNavigator"   
           [locale]="calendarFr" [readonlyInput]="true" [inline]="true" 
           [maxDateCount]="4" [selectionMode]="multiple">
</p-calendar>

Upvotes: 1

Views: 3110

Answers (2)

Mohammed Doulfakar
Mohammed Doulfakar

Reputation: 128

So apparently it's a bug in p-calendar, i didn't find any hack to fix it, i just removed the multiple selection and added the dates using onSelect event.

Here's the link to the issue : https://github.com/primefaces/primeng/issues/3876

Upvotes: 1

Antikhippe
Antikhippe

Reputation: 6655

Remove square brackets from selectionMode.

Replace [selectionMode]="multiple" by selectionMode="multiple".

Upvotes: 1

Related Questions