Fullcalendar选择额外的一天[有角度]

时间:2016-11-24 12:43:52

标签: angularjs fullcalendar momentjs

点击一个日期只选择一天,当我保存时,fullcalendar延长一天(选择2天而不是只有一天)。我在论坛上看到的是"有一天,"而不是"前一天" - 这是我的问题。一般来说,它会为我所选择的任何日期增加1天。这是angular中的配置部分。

fullcalendar angular

function clearCalendar(){
        if(uiCalendarConfig.calendars.myCalendar != null){
            uiCalendarConfig.calendars.myCalendar.fullCalendar('removeProjects');
            uiCalendarConfig.calendars.myCalendar.fullCalendar('unselect')
        }
    }

function populate() {
    clearCalendar();
    $http.get('/projs', {
        cache: false,
        params: {}
    }).then(function data) {

        angular.forEach(data.data, function (value) { 
            $scope.projects.push({ 
                projectID : value.projectID,
                client : value.client,
                title: value.title,
                description: value.description, 
                start: new moment(value.startAt),
                end: new moment(value.endAt),
                employees: value.employees,
                allDay: value.isFullDay,
                stick: true  
            });
        });
    });
}
populate();

$scope.uiConfig = {
        calendar: {
            height: 500,
            editable: true,
            displayEventTime: true,
            header: {
                left: 'month, agendaWeek, agendaDay',
                center: 'title',
                right: 'today prev,next'
            },

            selectable: true,
            selectHelper: true,

            select: function(start, end){
                $scope.showSelected = false;
                var fromDate = moment(start).format('DD/MM/YYYY LT');
                var endDate  = moment(end).format('DD/MM/YYYY LT');

                $scope.Project = { 
                    ProjectID : 0,
                    Client: '',
                    Title : '',
                    Description: '',
                    Employees: '',
                    StartAt : fromDate,
                    EndAt : endDate,
                    IsFullDay : false
                }

                $scope.ShowModal()
            },

            eventClick: function (project) { 
                $scope.showSelected = true;
                $scope.SelectedProject = project;

                var fromDate = moment(project.start).format('DD/MM/YYYY LT');
                var endDate  = moment(project.end).format('DD/MM/YYYY LT');

                $scope.Project = { 
                    ProjectID : project.projectID, 
                    Client : project.client,
                    Title : project.title,
                    Description: project.description,
                    Employees: project.employees,
                    StartAt : fromDate,
                    EndAt : endDate,
                    IsFullDay : false   
                }
                $scope.ShowModal()
            },

            eventAfterAllRender: function (){
                if($scope.projects.length > 0 && isFirstTime) {
                    uiCalendarConfig.calendars.myCalendar.fullCalendar('gotoDate', $scope.projects[0].start);
                    isFirstTime = false;
                }
            }
        }
    };

$scope.ShowModal = function(){
        $scope.option = {
            templateUrl: 'modalContent.html',
            controller: 'modalController',
            controllerAs: '$ctrl',
            backdrop: 'static',
            resolve: {
                Project : function () { 
                    return $scope.Project;
                },
                SelectedProject : function () { 
                    return $scope.SelectedProject;
                },
                projects: function () {
                    return $ctrl.projects;
                }
            }
        };

感谢您的帮助。

0 个答案:

没有答案