如何使用angular bootstrap日历给dtStart和Recurring事件?

时间:2016-08-24 16:07:12

标签: javascript java html angularjs spring-mvc

在angular js服务文件中,我在这里使用RRULE.WEEKLY,我想给dtStart,直到动态地使用多个事件

 $scope.$watchGroup([
                $scope.calendarView,
                angular.forEach(data, function (value, index) {
                    if(value.recursOn === 'week'){
                        $scope.viewDate = value.startDate,
                        $scope.viewEndDate = value.endDate
                    }
                }),
            ], function() {

          // Use the rrule library to generate recurring events: https://github.com/jkbrzt/rrule
          var rule = new RRule({
            freq: RRule.WEEKLY,
            interval: 1,
            byweekday: [RRule.MO],
            dtstart: moment($scope.viewDate).toDate(),
            until: moment($scope.viewEndDate).toDate()
          });

          angular.forEach(data, function (value, index) {
                    if(value.recursOn !== 'week'){
                    $scope.schedules.push(value);
                }

                });

          rule.all().forEach(function(date) {
            angular.forEach(data, function (value, index) {
                    if(value.recursOn === 'week'){
                    $scope.schedules.push({
                matchDesc: value.matchDesc,
                teamName: value.teamName,
                color: calendarConfig.colorTypes.success,
                startDate: new Date(date)
            });
                }

                });
          });

        });

在此我试图通过每周重复发送多个事件,所以为此我使用angular来从数据库获取事件但是如何设置多个事件开始日期和结束日期到dtStart直到。

1 个答案:

答案 0 :(得分:1)

为此你做的就是这样。

var rule = {};
       $scope.$watchGroup([
                $scope.calendarView,

            ], function() {
       angular.forEach(data, function (value, index) {
       // Use the rrule library to generate recurring events:https://github.com/jkbrzt/rrule

       if(value.recursOn === 'week'){
              rule = new RRule({
               freq: RRule.WEEKLY,
               interval: 1,
               byweekday: [RRule.MO],
               dtstart: moment(value.startDate).toDate(),
               until: moment(value.endDate).toDate()
             });
          }

       rule.all().forEach(function(date) {

                if(value.recursOn === 'week'){
              $scope.schedules.push({
                    matchDesc: value.matchDesc,
                    teamName: value.teamName,
                    color: calendarConfig.colorTypes.success,
                    startDate: new Date(date)
               });
              }
          });   
         });


    });

它每周使用RRULE.WEEKLY和dtstart一起为Recurring事件工作,直到动态地没有事件。

希望它会有所帮助。