Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angular/32.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript ionic:如何将数组的索引传递给getActiveIndex()方法?_Javascript_Angular_Ionic Framework_Ion Slides - Fatal编程技术网

Javascript ionic:如何将数组的索引传递给getActiveIndex()方法?

Javascript ionic:如何将数组的索引传递给getActiveIndex()方法?,javascript,angular,ionic-framework,ion-slides,Javascript,Angular,Ionic Framework,Ion Slides,我有一个数组,显示了一周中的几天,我需要通过今天的索引。我有一个名为compareFirstDay的全局变量,它显示的是今天,一周中有几天的对象数组名为this.showingWeekCalendar,因此当屏幕大小小于或等于768px时,我需要传递当天的索引位置,以便首先在幻灯片中显示今天 这个。显示WeekCalendar 0: {name: "Sunday", agenda: Array(0), date: "03/02/2019"} 1: {name: "Monday", agenda:

我有一个数组,显示了一周中的几天,我需要通过今天的索引。我有一个名为
compareFirstDay
的全局变量,它显示的是今天,一周中有几天的对象数组名为
this.showingWeekCalendar
,因此当屏幕大小小于或等于768px时,我需要传递当天的索引位置,以便首先在幻灯片中显示今天

这个。显示WeekCalendar

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: ""}
home.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();
                }
          }     
        }
//迭代本周的数组
对于(设i=0;i<7;i++){
//将今天的日期与一周中的日期进行比较,以找到正确的日期
如果(compareFirstDay===this.showingWeekCalendar[i].date){
如果(屏幕大小)
<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>