如何在ajax响应中设置日历中的日期

如何在ajax响应中设置日历中的日期,ajax,angularjs,Ajax,Angularjs,我正在使用angular js fullcalendar控件。我正在调用一个服务器方法,该方法在服务器方法的响应中返回我要在fullcalendar中设置的日期 我正在使用ajax进行服务器调用 以下是我所指的代码: myModule.controller('calendarController', ['$scope', '$timeout', function ($scope, $timeout) { var date = new Date(); var d = date.getDat

我正在使用angular js fullcalendar控件。我正在调用一个服务器方法,该方法在服务器方法的响应中返回我要在fullcalendar中设置的日期

我正在使用ajax进行服务器调用

以下是我所指的代码:

myModule.controller('calendarController', ['$scope', '$timeout', function ($scope, $timeout) {
  var date = new Date();
  var d = date.getDate();
  var m = date.getMonth();
  var y = date.getFullYear();
  // '1/25/2015 12:00:00 AM' AND dDueDate <= '3/8/2015 12:00:00 AM' 
  var GetEventData = {
    startDate: "1/25/2008 12:00:00 AM",
    endDate: "3/8/2016 12:00:00 AM",
    tabstate: "Org"
  };
  var url = window.opener.oT.TracerURL + "/DakotaScheduler.aspx/GetEventData";
  $.ajax({
    url: url,
    type: 'POST',
    data: JSON.stringify(GetEventData),
    contentType: "application/json; charset=utf-8",
    dataType: "json"
  }).done(function (response) {
    var eventdate = response.d.EventDataTable[0].EventDate;
    $scope.events = [{
        title: 'test',
        start: new Date(y, m, d, 3, 0),
        end: new Date(y, m, d, 4, 0)
    }];

    $scope.eventSources = [$scope.events];

  }).fail(function (jqXHR, textStatus, errorThrown) {
    console.log(errorThrown);
  });
  $scope.events = [{
        title: 'test',
        start: new Date(y, m, d, 3, 0),
        end: new Date(y, m, d, 4, 0)
    }];
    $scope.eventSources = [$scope.events];
}]);
ajax调用的done部分中的代码行并没有设置日期,但外部代码按预期工作

但我需要设置从服务器返回的日期值。

试试这个

$timeout(function () {
    $scope.eventSources = [$scope.events];
}, 0);

为什么要使用ajax而不是$http服务?我尝试过使用设置超时,但仍然不起作用。
$timeout(function () {
    $scope.eventSources = [$scope.events];
}, 0);