Angularjs 如何在日历中以JS显示事件?
我用 如何从AJAX在日历中显示所有事件? 我想我需要从响应AJAX填充数组事件 我的PHP:Angularjs 如何在日历中以JS显示事件?,angularjs,Angularjs,我用 如何从AJAX在日历中显示所有事件? 我想我需要从响应AJAX填充数组事件 我的PHP: foreach($calendar as $val){ $this->outputData["calendar"][] = array( "title" => $val->DetailToUsersName, "type" => 'i
foreach($calendar as $val){
$this->outputData["calendar"][] = array(
"title" => $val->DetailToUsersName,
"type" => 'info',
"startsAt" => "Sat Jun 01 2015 01:00:00 GMT+0500",
"endsAt" => "Sat Jun 01 2016 01:00:00 GMT+0500",
"resizable" => true,
"incrementsBadgeTotal" => true,
"recursOn" => 'year'
);
}
echo json_encode($this->outputData);
是的,您需要将AJAX响应转换为中定义的格式:
使用这些字段创建一个数组并进行json_编码?ajax响应返回什么?问题是在ajax之前加载了我的日历。只需传递一个空数组,并在收到数据时填充它。日历将自行更新。M y AJAX返回以下内容:0:endsAt:Sat Jun 01 2016 01:00:00 GMT+0500增量sBadgeTotal:true recursOn:year可调整大小:true startsAt:Sat Jun 01 2015 01:00:00 GMT+0500标题:Sb类型:信息
$scope.events = [
{
title: 'My event title', // The title of the event
type: 'info', // The type of the event (determines its color). Can be important, warning, info, inverse, success or special
startsAt: new Date(2013,5,1,1), // A javascript date object for when the event starts
endsAt: new Date(2014,8,26,15), // Optional - a javascript date object for when the event ends
editable: false, // If edit-event-html is set and this field is explicitly set to false then dont make it editable.
deletable: false, // If delete-event-html is set and this field is explicitly set to false then dont make it deleteable
draggable: true, //Allow an event to be dragged and dropped
resizable: true, //Allow an event to be resizable
incrementsBadgeTotal: true, //If set to false then will not count towards the badge total amount on the month and year view
recursOn: 'year', // If set the event will recur on the given period. Valid values are year or month
cssClass: 'a-css-class-name' //A CSS class (or more, just separate with spaces) that will be added to the event when it is displayed on each view. Useful for marking an event as selected / active etc
}
];