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

Event rendering problem #345

Open Sehur opened 8 years ago

Sehur commented 8 years ago

Im having problems with the rendering of the events at the calendar, Im getting the events from a database and sometimes they get displayed at the calendar but sometimes this error shows up:

TypeError: Cannot read property 'length' of null

Im not sure why sometimes it works and sometimes it doesnt. Here is an example of how im filling the arrays $scope.events = [];

$http.get(url).success(function(data){  //fetch new events from server, and push in array
               for(var i=0;i<data.length;i++)
                {
                  $scope.events.push({
                  title: data[i].idReserva,
                  start: new Date(data[i].fechaInicio), 
                  end:  new Date(data[i].fechaFin),
                  sticky: true,
                  allDay: false
                  });
                }
    });

$scope.events2 = {
  color: 'black',
  textColor: 'white',
  events:[]
};

$http.get(url).success(function(data){  
               for(var i=0;i<data.length;i++)
                {
                  $scope.events2.events.push({
                  title: data[i].idReserva,
                  start: new Date(data[i].fechaInicio), 
                  end:  new Date(data[i].fechaFin),
                  sticky: true,
                  allDay: false
                  });
                  console.log(data[i].idReserva)
                }
    });

$scope.eventSources = [$scope.events, $scope.events2]

Sehur commented 8 years ago

In case someone gets my same mistake, I had an error in the changeLang() method, I've just noticed that when I changed the language the calendar started working.

My mistake

mariohmol commented 8 years ago

is this the case to close the issue?

Sehur commented 8 years ago

Yeah it was the render problem that was solved in another thread, thanks