These are chat archives for angular-ui/ui-calendar

10th
Dec 2015
acejohn
@acejohn
Dec 10 2015 07:06
@claudiooliv did you try to fetch data from a hosting then put it to your calendar? I need some help regarding with this.
This message was deleted
I have a problem to get all the data from a service. As you can see I used this plugin https://github.com/EddyVerbruggen/Calendar-PhoneGap-Plugin. And I have a service which will fetch all the data. It seems okay once I started to launch the application. All the information fills the date in calendar. But when I tried to press the next and previous button it shows nothing and all the dates from calendar was deleted. I have this thought that it is because the service was once called only. i want to make a variable that will catch all the data from foreach function inside the service then used for the calendar function outside the service. How will I do that? Or any solution that will answer my question. Best regards to all! Thank You.

(function(){

var app = angular.module('myApp.calendar',[])
app.controller('CalendarCtrl', function($scope, $compile, $timeout, uiCalendarConfig,NetworkAvailability, UserFactory)
{

  var date = new Date();
  var d = date.getDate();
  var m = date.getMonth();
  var y = date.getFullYear();

  $scope.allEventHere = {};

  var datestart = {};
  var dateend = {};

  var Dd;
  var Mm;
  var Yy;

  $scope.sdateFormat  = {};
  $scope.edateFormat  = {};

  $scope.dateRawData = {};
  $scope.events = [];
  $scope.dateData = [];
  $scope.dateRaw = {};

  $scope.doRefresh = function() {

  };

  UserFactory.getUserEvents().then(function (response) 
  {
    $scope.dateRawData  =   UserFactory.userEvents();
    $scope.swanity  =   UserFactory.getItemByEvents();

     angular.forEach($scope.dateRawData , function(value, key) 
     {           

      datestart  = new Date(parseInt(value.start) * 1000);
      dateend  = new Date(parseInt(value.end) * 1000);

          $scope.sdateFormat = {       
                sdateYr: datestart.getFullYear(),
                sdateMon: datestart.getMonth(),
                sdateDy: datestart.getDate() + 1,
                sdateHr: datestart.getHours(),
                sdateMin: datestart.getMinutes(),
                sdateSec: datestart.getSeconds() 
            }

            $scope.edateFormat = {  
                edateYr: dateend.getFullYear(),
                edateMon: dateend.getMonth(),
                edateDy: dateend.getDate() + 1,
                edateHr: dateend.getHours(),
                edateMin: dateend.getMinutes(),
                edateSec: dateend.getSeconds() 
            }



         $scope.dateRaw = {
                          title: value.title, 
                          start: value.start, 
                          end: value.end, 
                          description: value.description
                        };

         $scope.dateData = [
                          {
                            title: $scope.dateRaw.title, 
                            start: new Date($scope.sdateFormat.sdateYr,
                              $scope.sdateFormat.sdateMon,$scope.sdateFormat.sdateDy, $scope.sdateFormat.sdateHr, $scope.sdateFormat.sdateMin, $scope.sdateFormat.sdateSec), 
                            end: new Date($scope.edateFormat.edateYr, $scope.edateFormat.edateMon,$scope.edateFormat.edateDy, $scope.edateFormat.edateHr, $scope.edateFormat.edateMin, $scope.edateFormat.edateSec)
                          }
                      ];  

                        for(var i = 0; i < $scope.dateData.length;i++) 
                        {

                           $scope.events.push(  
                                                {
                                                   title: $scope.dateData[i].title,
                                                   start: $scope.dateData[i].start,
                                                   end: $scope.dateData[i].end 
                                                }                                                              
                                              );            
                        } 

      });

  });



  $scope.eventSource = 
  {
      url: "http://www.google.com/calendar/feeds/usa__en%40holiday.calendar.google.com/public/basic",
      className: 'gcal-event',           
      currentTimezone: 'America/Chicago' 
  };

  $scope.eventsF = function (start, end, timezone, callback) 
  {

      var s = new Date(start).getTime() / 1000;
      var e = new Date(end).getTime() / 1000;
      var m = new Date(start).getMonth();
      var events = [{title: 'Feed Me ' + m,start: s + (50000),end: s +
      (100000),allDay: false, className: ['customFeed']}];
      callback(even