我正在尝试根据日期将数据库中的所有事件显示到mwl日历中。但是现在所有事件都显示在今天的日期。如何根据保存在数据库中的日期显示事件。 ?
HTML
<mwl-calendar
events="events"
view="calendarView"
current-day="viewDate"
view-title="calendarTitle"
ng-model="eventSources"
cell-is-open="cellIsOpen"
day-view-start="06:00"
day-view-end="22:59"
day-view-split="30"
cell-modifier="modifyCell(calendarCell)"
cell-auto-open-disabled="true"
on-timespan-click="timespanClicked(calendarDate)">
</mwl-calendar>
控制器
$scope.myevents = function(start, end, timezone, callback) {
SalesNotifyService.getAllNotify().success(function(data) {
$scope.events = [];
angular.forEach(data,function(event,key){
$scope.events.push({
employeeName: event.employeeName,
notifyDate: event.notifyDate,
});
});
callback($scope.events);
});
}
$scope.eventSources = [$scope.events,$scope.myevents];
我想基于notifyDate显示事件。如果notifyDate是12-12-2020,那么在12-12-2020的日历中它应该显示与该notifyDate相关的employeeName。任何人都可以告诉如何根据notifyDate显示事件从数据库?
答案 0 :(得分:1)
每个事件对象都需要以下属性:
尝试使用这些属性构建对象
SalesNotifyService.getAllNotify().success(function(data) {
$scope.events = [];
angular.forEach(data,function(event,key){
$scope.events.push({
title: event.employeeName,
startsAt: event.notifyDate, // needs to be a javascript date object
color: {
primary: '#e3bc08',
secondary: '#fdf1ba'
},
});
});
}