angular-ui / ui-calendar

A complete AngularJS directive for the Arshaw FullCalendar.
http://angular-ui.github.io/ui-calendar/
MIT License
1.49k stars 729 forks source link

Use $http to make Ajax request instead of $.ajax #152

Open sagar-ganatra opened 10 years ago

sagar-ganatra commented 10 years ago

The _fetchEventSource method uses $.ajax to send a request. When working on an application where the data is served from Angular mock ($httpBackend), the request does not get served by the mock server. Is there any workaround to this?

If fullcalendar.js can use $http instead of $.ajax from jquery, requests would get served correctly.

LeleDev commented 9 years ago

I'm interested in this issue too.. any ideas?

sagar-ganatra commented 9 years ago

I was able to fix this issue, in the 'eventSource' object mention 'events' property:

$scope.eventSource = { events: function (param1, param2) { contactCalendarService.getContactCalendar(param1, param2) .then(function (response) { //process response here }); } };

LeleDev commented 9 years ago

Mmh I'm not sure to understand your solution! How does this code help to get angular mock working with fullcalendar?

hectorsq commented 9 years ago

In the template I have the following code:

<div ui-calendar="uiConfig.calendar" ng-model="appointments" id="allAppointments"></div>

In the controller I configure a viewRender callback

  $scope.uiConfig = calendar:
    viewRender: $scope.getAppointments

and have the following function to get the data

  $scope.getAppointments = (view, element) ->
    restAppointments = Restangular.all('appointments')
    restAppointments.getList({start: view.start.format(), end: view.end.format()}).then(
      (appointments) ->
        $scope.remoteAppointments = appointments
        $scope.appointments.length = 0
        $scope.appointments.push $scope.remoteAppointments
    )

In this particular case I am using Restangular but I am planning to replace it with plain $http