Javascript 如何使用角度引导日历为周期性事件指定dtStart和TILL?

Javascript 如何使用角度引导日历为周期性事件指定dtStart和TILL?,javascript,java,html,angularjs,spring-mvc,Javascript,Java,Html,Angularjs,Spring Mvc,在angular js服务文件中,我在这里使用RRULE.WEEKLY,我想用多个事件动态地给出dtStart和until $scope.$watchGroup([ $scope.calendarView, angular.forEach(data, function (value, index) { if(value.recursOn === 'week'){

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

 $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 for each从数据库获取事件,但如何将多个事件的开始日期和结束日期设置为dtStart和until

为此,您必须这样做

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以及until来处理每周重复事件,并动态更改为无事件

希望能有帮助