angular-ui / ui-calendar

A complete AngularJS directive for the Arshaw FullCalendar.
http://angular-ui.github.io/ui-calendar/
MIT License
1.49k stars 728 forks source link

Set calendar current date #464

Open AlphaNerd opened 7 years ago

AlphaNerd commented 7 years ago

How do you set the calendars current view date dynamically from controller. I want to be able to click a day in the month view and auto switch to that day in dayView.

mohamed-magdy commented 7 years ago

+1

CurtisVayne commented 7 years ago

in the calendar ui config, attach the dayclick event: dayClick: $scope.alertOnDayClick

in the event handler, you can switch view, and jump to the date: $scope.alertOnDayClick = function (date, jsEvent, view, resource) { if (view.name !== 'month') return; uiCalendarConfig.calendars.myCalendar1.fullCalendar('changeView', 'agendaDay'); uiCalendarConfig.calendars.myCalendar1.fullCalendar('gotoDate', date ); }

myCalendar1 is the name of the calendar in the HTML: <div class="calendar" ng-model="eventSources" calendar="myCalendar1" ui-calendar="uiConfig.calendar"></div>

vilasdh1232 commented 7 years ago

Thanks Curtis Vayne. It works.