Problem displaying events (displays only the first)
Abdou00 opened this issue · 2 comments
Abdou00 commented
Bug description / Feature request:
Hello,
I solicit you because I have a curious problem I connect my calendar to my database mongo, I manage to recover all my events as the console shows but only the first one is displayed. And I have to acknowledge that I'm getting into idea there. Someone would have any idea??
My controller:
// Récupère les plannings depuis la base de donnée
vm.planningCalendar = vm.plannings;
vm.planningCalendar.$promise.then(function (resourceArray) {
// Crée un array vide pour y stocker les plannings
$scope.allPlannings = [];
$scope.allPlannings = resourceArray;
// Boucle dans le tableau des plannings
angular.forEach($scope.allPlannings, function (data) {
// Crée une vue des plannings dans le calendrier
$scope.planningView = [
{
title: data.name,
color: calendarConfig.colorTypes.warning,
startsAt: moment(new Date(data.start))/*.startOf('year').month(monthStart).date(dateStart)*/,
endsAt: moment(new Date(data.end))/*.startOf('year').month(monthEnd).date(dateEnd)*/,
team: data.team,
site: data.site,
tasks: data.tasks,
draggable: true,
resizable: true,
actions: actions
}
];
console.log($scope.planningView);
});
});
Versions
Angular: ~1.3
MeanJS: 0.4.2
Calendar library: v0.29.3
Browser name and version: Chrome | Version 59.0.3071.115
burtek commented
angular.forEach($scope.allPlannings, function (data) {
// Crée une vue des plannings dans le calendrier
$scope.planningView = [
{
//... calendar item
}
];
console.log($scope.planningView);
});
You override $scope.planningView
(which I understand is the calendar view) each time. You should not assign the array to $scope.planningView
each time, but rather append them:
angular.forEach($scope.allPlannings, function (data) {
// Crée une vue des plannings dans le calendrier
$scope.planningView.push({
//... calendar item
});
console.log($scope.planningView);
});
Abdou00 commented
Ah okay, thanks its works !!
Thank you for your help ;)