如何在加载到url时按照fullcalendar显示发送月份(angularJs)

how to send a month in accordance with fullcalendar display when loaded into a url (angularJs)

伙计们。

我对 angularJs 的 fullCalendar 有一些疑问。

我有配置全日历的代码:

.controller('MyController', function($scope) {
    /* config object */
    $scope.uiConfig = {
      calendar:{
        height: 450,
        editable: true,
        header:{
          left: 'month basicWeek basicDay agendaWeek agendaDay',
          center: 'title',
          right: 'today prev,next'
        }
      }
    };
});

加载成url(angularJs)

时如何按照fullcalendar显示发送月份

使用viewRender回调,您可以在其中访问实际显示的日期范围(startend

.controller('MyController', function($scope, MyService) {

    var eventSources;

    var myCallbackFn = function(view, element){
      var start = view.start;
      var end = view.end;
      // to get month only in format '01', '02' ... '12'
      var dateFormat = 'MM';
      var startMonth= start.format(dateFormat);
      // then to load events you could use something like this
      // just an example
      MyService.getEvents(startMonth).then(function(response) {
        eventSources = response;
      });
    }

    /* config object */
    $scope.uiConfig = {
      calendar:{
        height: 450,
        editable: true,
        header:{
          left: 'month basicWeek basicDay agendaWeek agendaDay',
          center: 'title',
          right: 'today prev,next'
        },
        viewRender: myCallbackFn
      }
    };
});