p-calendar and range

UI Components for Angular
Post Reply
D0minik
Posts: 15
Joined: 15 Jan 2018, 09:09

18 Jan 2018, 14:46

Hi everybody,

i need some help with the calendar-functionality and the option "range".

I don´t understand, how i get the two dates into in array without using the [(ngModel)]?

ctran2428
Posts: 41
Joined: 27 Apr 2017, 04:15

18 Jan 2018, 17:51

What are you trying to do? Reactive Forms? or just plain Datepicker?

D0minik
Posts: 15
Joined: 15 Jan 2018, 09:09

18 Jan 2018, 18:07

ctran2428 wrote:
18 Jan 2018, 17:51
What are you trying to do? Reactive Forms? or just plain Datepicker?
I want to do a Datepicker with a inline Calendar (have a look at the link: https://www.primefaces.org/primeng/#/calendar), where i can select a range.

I have created a service that sends the selected data to a component (not a Mother-Child-Relation, so Binding doesn´t work).

I do not know how it works without the ng-Model. I just want to have the range data in an array that will be send with the created service function.

ctran2428
Posts: 41
Joined: 27 Apr 2017, 04:15

18 Jan 2018, 19:27

Instead of [(ngModel)], you can do [ngModel] and (ngModelChange) then bind (ngModelChange) to a method in your component that is going to handle the data from p-calendar. If it's not inside of a Form (which is a standalone DatePicker just to get you a Date range), then ngModel and ngModelChange would help you achieve what you need. Other than that, you need to elaborate more on your use-case so I can help you.

D0minik
Posts: 15
Joined: 15 Jan 2018, 09:09

19 Jan 2018, 09:23

ctran2428 wrote:
18 Jan 2018, 19:27
Instead of [(ngModel)], you can do [ngModel] and (ngModelChange) then bind (ngModelChange) to a method in your component that is going to handle the data from p-calendar. If it's not inside of a Form (which is a standalone DatePicker just to get you a Date range), then ngModel and ngModelChange would help you achieve what you need. Other than that, you need to elaborate more on your use-case so I can help you.
That was the solution! Thank you very much! :D :D :D

tednice75
Posts: 4
Joined: 22 Jan 2018, 20:43

22 Jan 2018, 21:22

My question is similar. Right now, I have multiple inline calendars on my page. The calendar component does not allow me to select dates that range across two consecutive months. The range feature allows you to select across multiple months in the same calendar. That means if I have Jan, Feb, Mar..., if I select a range from Jan to Feb, the calendar now reads Feb, Feb, Mar... If I change the selection type and handle the highlighting manually, how to I update the model?

Post Reply

Return to “PrimeNG”

  • Information
  • Who is online

    Users browsing this forum: No registered users and 17 guests