2016-09-30 54 views
0

如何从json url(/ comments)渲染我的fullcalendar时间?它显示时间应该显示的“对象对象”。从json网址获取时间的正确方法是什么?从URLFullcalendar:如何从json url渲染时间 - 类型错误hasTime()

JSON例如

{"Title": "qwerty", "Description": "asdf", "IsFullDay": null, "EndAt": "2016-09-21T09:10:15.549000", "StartAt": "2016-09-21T09:10:15.549000"}

fullcalendar

enter image description here

从 “fullcalendar.min”

错误个

enter image description here

enter image description here

controller.js

function populate() { 
     clearCalendar(); 
     $http.get('/comments', { 
      cache: true, 
      params: {}, 
     }).then(function (data) { 
      $scope.projects.slice(0, $scope.projects.length); 
      angular.forEach(data.data, function (value) { 
       $scope.projects.push({ 
        // id : value.ProjectID, 
        title: value.Title, 
        description: value.Description, 
        start: new Date(value.StartAt), 
        end: new Date(value.EndAt), 
        allDay: value.IsFullDay, 
        stick: true 
       }); 
      }); 
     }); 
} 

//configure calendar 

$scope.uiConfig = { 
    calendar: { 
     eventSources:{ 
       url: '/comments', 
     }, 
     height: 500, 
     editable: true, 
     displayEventTime: true, 
     header: { 
      left: 'month, agendaWeek, agendaDay', 
      center: 'title', 
      right: 'today prev,next' 
     }, 
     timeFormat : { 
      month: ' ', //for hide on month view 
      agenda: 'h:mm: t' 
     }, 
     selectable: true, 
     selectHelper: true, 
     select: function(start, end){ 
      var fromDate = moment(start).format('DD/MM/YYYY LT'); 
      var endDate = moment(end).format('DD/MM/YYYY LT'); 

      $scope.NewProject = { 
       ProjectID : 0, 
       StartAt : fromDate, 
       EndAt : endDate, 
       IsFullDay : false, 
       Title : '', 
       Description: '' 
      } 
      $scope.ShowModal() 
     }, 
+0

展开错误并查看代码中源自的位置。 – Ryan89

+0

@ Ryan89它来自fullcalendar.min不能改变该代码当然 –

+0

没有点击左侧的箭头,并跟踪到你的代码中源于它的痕迹。只有来自fullcalendar.min和jquery.min的 – Ryan89

回答

0

溶液简单地(未客观化)变化

timeFormat : { 
     month: ' ', //for hide on month view 
     agenda: 'h:mm: t' 
    }, 

timeFormat : 'h:mm: t' 

或任何格式你想要或者只是删除timeFormat总共(将自动解析为默认值)

0

在你填入你的函数开始和结束日期,使用Javascript Date对象由,不会与fullCalendar工作,它需要时刻日期对象。更改以下

start: new Date(value.StartAt), 
end: new Date(value.EndAt), 

在此情况下,这

start: moment(value.StartAt), 
end: moment(value.EndAt), 
+0

之上的快照,与之前相同的hasTime错误 –