首页 > 解决方案 > 如何使用 AngularJS 显示完整的日历动态事件?

问题描述

从 Web 服务获取数据并将响应放入calendarlist变量中。以下是我的示例代码。提前致谢。

<div id="calendar" 
     ui-calendar="uiConfig.calendar" 
     class="span8 calendar" 
     ng-model="calEvents"></div>
$scope.calender1 = function() {
  $scope.events = [];
  //getting data from server
  $http({
    //web service calling here
  }).then(function successCallback(response) {
    //response is json array
    var calendarlist;
    $scope.calendarlist = response.data.result;
    //for loop for event display
    for (var i = 0; i < $scope.calendarlist.length; i++) {
      $scope.events[i] = {
        title: $scope.calendarlist[i].Schedulername,
        start: $scope.calendarlist[i].startdate,
      };
    }
    //initalizing the array   
    $scope.eventSources = [$scope.events];
    console.log("$scope.eventSources" + $scope.eventSources);
  }, function errorCallback(response) {});
}

标签: jqueryangularjsfullcalendar

解决方案


推荐阅读