javascript - 如何在AngularJS中的fullcalendar中动态设置多个事件?

标签 javascript angularjs cordova fullcalendar

我想在我的全日历中设置许多事件

这是我的 Controller :

$http.get('http://127.0.0.1:8080/elodieService/reservations/'+$localStorage.idconsommateur+'/m', { params: { "idconsommateur":$localStorage.idconsommateur, fields: "nom,prenom,login,imageJson",format:"json"} }).then(function(result) {

 for (var int = 0; int < result.data.length; int++) {
            console.log(result.data[int].idevenement.titre_annonce);
            var d= new Date(result.data[int].idevenement.date_evenement);


    $scope.uiConfig = {
             calendar:{
                    height: 450,
                    editable: true,
                    lang: 'fr',

                    events: [


                {
                  title: result.data[int].idevenement.titre_annonce,
                  start: d,
                   allDay: true,
                 },
]
}
}
});

在我的 calendar.html 中

<div ui-calendar="uiConfig.calendar" ng-model="eventSources" calendar="myCalendar">

但我总是只找到我的全日历中的最后一个事件,我想找到我的全日历中的所有事件。我该怎么做才能得到这个?请帮助我

最佳答案

您必须在 for 循环之外配置日历。

试试这个。

$http.get('http://127.0.0.1:8080/elodieService/reservations/'+$localStorage.idconsommateur+'/m', { params: { "idconsommateur":$localStorage.idconsommateur, fields: "nom,prenom,login,imageJson",format:"json"} }).then(function(result) 
{
    var calEvents = [];
    for (var int = 0; int < result.data.length; int++) {
    console.log(result.data[int].idevenement.titre_annonce);
        var d= new Date(result.data[int].idevenement.date_evenement);
        calEvents.push(
        {
        title: result.data[int].idevenement.titre_annonce,
        start: d,
        allDay: true
        }
    );
      }
      $scope.uiConfig = {
          calendar:{
              height: 450,
              editable: true,
              lang: 'fr',
              events: calEvents
          }
      }
});

关于javascript - 如何在AngularJS中的fullcalendar中动态设置多个事件?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/34924005/

相关文章:

php - AJAX 和 PHP - 检索多个值

javascript - 如何将任何数组从 ng-repeat 传递到 AngularJs 属性指令?

javascript - AngularJS Controller 内的嵌套应用程序

javascript - 如何将设备转到按钮标签名称 'go' 更改为 'next' ?

javascript - 带有附件的电子邮件编辑器 Phonegap 插件无法在 iOS 中使用 imageURI

android - 无法使用 strophe.js 使用 openfire 服务器连接到 phonegap 中的 xmpp 服务器

javascript - 打印 getElementsByClassName

Javascript没有解析相对于当前脚本的工作路径

javascript - 如何使用 jquery 简化我的代码?

angularjs - Angular - 无法在 ng-switch-when 内观看