2014-11-23 57 views
1

我想在Urigo的角流星中使用ui-calendar。我這樣編碼,它不起作用,但我不知道爲什麼以及如何解決它。 集合不是空的,但事件不會出現在日曆中。感謝您的關注。 https://github.com/wuxianliang/ui-calendar-angular-meteor在Urigo的角流星上使用UI日曆的正確方法是什麼?

CalEvents = new Mongo.Collection("calevents"); 
CalEvents.allow({ 
    insert: function() { 
     return true; 
    }, 
    update: function() { 
     return true; 
    }, 
    remove: function() { 
     return true; 
    } 
}); 

if (Meteor.isClient) { 

angular.module('Calendardemo', ['angular-meteor', 'ui.calendar','ui.router', 'angularMoment','mgcrea.ngStrap','ngAnimate']); 

Meteor.startup(function() { 
    angular.bootstrap(document, ['Calendardemo']); 
}); 

angular.module('Calendardemo').controller('MyCalendar', [ 
    '$scope', 
    '$collection', 
    function($scope, $collection) { 
     $collection(CalEvents).bind($scope,'calevents',true,true); 


     $scope.addCalEvent=function(date, jsEvent, view){ 
      var startDateTime = moment(date).format('YYYY-MM-DDTHH:mm:ss.SSSZ'); 
      var endDateTime = moment(date).add(1, 'h').format('YYYY-MM-DDTHH:mm:ss.SSSZ'); 
      $scope.calevents.push({ 
       title: 'New Event', 
       start: startDateTime, 
       end: endDateTime, 
       completed: null, 
       doing: null 
      }) 

     }; 
     $scope.eventRender = function(event,element){}; 
     /* config object */ 
     $scope.uiConfig = { 
      calendar:{ 
       height: 450, 
       defaultView: 'month', 
       lang: 'en', 
       eventColor: 'grey', 
       header:{ 
        left: 'prev next today', 
        center: 'title', 
        right: 'month agendaWeek' 
       }, 
       dayClick: $scope.addCalEvent, 
       eventRender: $scope.eventRender, 
       editable: true, 
       selectable: true, 
       allDayDefault: false 
      } 
     }; 
     $scope.eventSources = [$scope.calevents]; 
    }]);} 
if (Meteor.isServer) { 
    Meteor.publish('calevents', function(){ 
     return CalEvents.find(); 
    }) 
}  

回答

相關問題