如何转换JSON字段名称以匹配Angular中的Fullcalendar对象(angular ui-calendar)?

时间:2015-10-30 10:29:39

标签: json angularjs fullcalendar

我正在使用Angular ui-calendar,它是Arshaw FullCalendar的Angular版本。我的问题是日历本身需要一个“标题”字段,而我必须使用预定义的模型进行约会,而这些约会没有这样的字段。空的JSON模型如下所示:

"Appointment": {
            "resourceType": "Appointment",
            "identifier": [],
            "status": {},
            "type": {},
            "reason": "",
            "priority": {},
            "description": "",
            "start": "",
            "end": "",
            "minutesDuration": "",
            "slot": [],
            "comment": "",
            "participant": [{
                    "type": [],
                    "actor": [],
                    "required": [],
                    "status": []
                }] //End of "Appointment"
        }

我正在尝试将“description”字段名称转换为我的日历选项中的“标题”。目前,没有eventDataTransform,基本配置是:

calendarController.calendarOptions = {
                    calendar: {
                        lang: 'bg',
                        height: 450,
                        editable: true,
                        selectable: true,
                        events: calendarController.searchSet,
                        dataType: "json",
                        eventColor: '#30ACFF',
                        header: {
                            right: 'month agendaWeek agendaDay today prev,next'
                        },
                        timeFormat: 'H(:mm)'
                    }

                };

我在GitHub gist上找到了example字段名称转换,但它不是符合AngularJS的配置,而且我在我的应用程序中没有使用ajax调用,我正在使用服务来从中获取数据服务器:

calendarController.searchSet = CalendarService.search({type: 'Appointment'});

因此,它不适用于Angular应用程序,并且用于ui-calendar配置的Angular Docs几乎不存在。所以基本上,我得到一个在日历中显示但没有标题的事件。如果您使用带有Angular和RESTful服务的Fullcalendar来获取数据并使用正确的字段名称填充日历,而不修改预约的预定义模型,那么配置事件字段名称转换的正确方法是什么?

0 个答案:

没有答案