1

我有一个离子滑块,它以数组的形式显示一周中的几天,我需要传递今天的索引。我有一个名为的全局变量compareFirstDay,它显示今天是今天,并且调用了带有星期几的对象数组this.showingWeekCalendar,所以当屏幕尺寸较小或等于 768px 时,我需要传递当天的索引位置是今天来显示这一天首先在幻灯片。

this.showingWeekCalendar

0: {name: "Sunday", agenda: Array(0), date: "03/02/2019"}
1: {name: "Monday", agenda: Array(0), date: "04/02/2019"}
2: {name: "Tuesday", agenda: Array(0), date: "05/02/2019"}
3: {name: "Wednesdey", agenda: Array(0), date: ""}
4: {name: "Thursday", agenda: Array(0), date: ""}
5: {name: "Friday", agenda: Array(0), date: ""}
6: {name: "Saturday", agenda: Array(0), date: ""}

主页.ts

//iterate the array of the week
       for (let i = 0; i < 7; i++) {  
          //compare date of today with the days of the week to find the right day
          if (compareFirstDay === this.showingWeekCalendar[i].date) {               

                if (screenSize <= 768) {
                 //how can i pass the parameter to the method to show the position of the day
                  this.showingWeekCalendar[i].getActiveIndex();
                }
          }     
        }

HTML

<ion-slides pager="false" [options]="slideOpts" (ionSlidesDidLoad)="ionSlidesLoaded()">
          <ion-slide class="day-calendar" *ngFor="let weekAgenda of showingWeekCalendar">
            <p class="text-center slides-control m-t-10">
              <ion-button shape="round" fill="clear" (click)="slideBack()" *ngIf="slidesdidLoad"><i class="mdi mdi-chevron-left"></i></ion-button>
              {{weekAgenda.name}}<br>
              {{weekAgenda.date}}
              <ion-button shape="round" fill="clear" (click)="slideForward()" *ngIf="slidesdidLoad"><i class="mdi mdi-chevron-right"></i></ion-button>
            </p>
            <mwl-calendar-day-view [hourSegments]="4" [locale]="locale" [viewDate]="viewDate" [events]="weekAgenda.agenda"
              [refresh]="refresh" [eventWidth]="180" (eventClicked)="handleEvent($event.event)" (eventTimesChanged)="eventTimesDayChanged($event)"
              (hourSegmentClicked)="hourSegmentClicked($event.date, weekAgenda)" [dayStartHour]="weekViewWorkingHours.start" [dayEndHour]="weekViewWorkingHours.end">
            </mwl-calendar-day-view>
          </ion-slide>
        </ion-slides>

如果需要更多信息,请在评论中告诉我。谢谢你

4

0 回答 0