2016-09-30 37 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錯誤 –