首页 > 解决方案 > FullCalendar:在调用 RestAPI 调用后将 JSON 数据与 initialEvents 绑定

问题描述

运行作者网站上提供的角度全日历控制项目。我正在从服务器中以 JSON 形式在数组中获取事件(API ref),然后想与 initialEvents (API ref)绑定。我怎样才能做到这一点?

[
  {
    "id": 202081,
    "start": "2020-08-01",
    "isWorkDay": false,
    "budgetDailyNumber": 0,
    "modifiedBudgetDailyNumber": 0
  },
  {
    "id": 202082,
    "start": "2020-08-02",
    "isWorkDay": false,
    "budgetDailyNumber": 0,
    "modifiedBudgetDailyNumber": 0
  }
]

标签: javascriptangularfullcalendarfullcalendar-5

解决方案


这是解决方案:

events: {
  url: 'type URL here',
  method: 'GET',
  // extraParams: {
  //   custom_param1: 'something',
  //   custom_param2: 'somethingelse'
  // },
  failure: function() {
    alert('there was an error while fetching events!');
  },
  color: 'yellow',   // a non-ajax option
  textColor: 'black' // a non-ajax option
}

推荐阅读