satish kumar V
satish kumar V

Reputation: 1755

Get start date and end date in full calendar for a view in angularjs

How can I get the start and end time of visible days in fullcalendar?

I need it for use in another javascript instance. Is there some function like -

uiCalendarConfig.calendars['myCalendar1'].fullCalendar('getView').visStart

?

Upvotes: 0

Views: 3845

Answers (2)

Karl
Karl

Reputation: 3099

Following example shows fullcalendar in angular 2. Should be easily adaptable to your environment. You can use the "viewRender" callback of fullcalendar to maintain the current visible date range. Useful if you intend to fetch business objects only relevant for the visible date range, etc.

var calendarDiv: any;
var self = this;

calendarDiv = $(this.elementRef.nativeElement).find('#calendar');
calendarDiv.fullCalendar({
        defaultView:    "agendaWeek",
        ...
        viewRender: function (view: any, element: any) {
            self.crtCalendarStart = view.start;
            self.crtCalendarEnd = view.end;
            self.myFilterService.setFilter("filter_plandate", {
                type:   'DateTime',
                value_from: view.start.toDate(),
                value_to: view.end.toDate()
            });
        },
        selectable: true,
        selectHelper: false,
        ...
      });

Upvotes: 1

Ilya Luzyanin
Ilya Luzyanin

Reputation: 8110

According to full-calendar documentation (jQuery plugin on on which the uiCalendar is based on) when you call fullCalendar('getView') you get back the View object with properties:

start A Moment that is the first visible day.

end A Moment that is the exclusive last visible day.

So you should be able to get start and end moments as follows:

uiCalendarConfig.calendars['myCalendar1'].fullCalendar('getView').start

and

uiCalendarConfig.calendars['myCalendar1'].fullCalendar('getView').end

Upvotes: 1

Related Questions