在离子日历应用程序中设置星期六和星期日不可点击

时间:2018-05-05 14:21:09

标签: javascript angular typescript ionic-framework

我在互联网上看过一个教程: " https://devdactic.com/ionic-calendar-app/"关于如何在离子中做一个事件日历,我已经做了但是我有一个问题,如果我想让周六和周日例如不可爱(不能在所有周六和周日设置事件),

我的日历html文件:

         <ion-header>

        <ion-navbar color="BlueNew">
       <ion-title>
        Home
        </ion-title>

         <ion-buttons start>
         <button ion-button icon-only (click)="addEvent()">
         <ion-icon name="mail"></ion-icon>
        </button>
        </ion-buttons>

        </ion-navbar>

        </ion-header>
         <ion-content>
       <p style="text-align:center;">{{ viewTitle }}</p>
       <ion-navbar color="white">

        <ion-buttons end>

        <button ion-button [disabled]="isToday" (click)="today  ()">Today</button>
        <button ion-button (click)="changeMode('day')">D</button>
        <button ion-button (click)="changeMode('week')">W</button>
        <button ion-button (click)="changeMode('month')">M</button>



        </ion-buttons>
        </ion-navbar>

            <calendar [eventSource]="eventSource"
            [calendarMode]="calendar.mode"
            [currentDate]="calendar.currentDate"
           (onEventSelected)="onEventSelected($event)"
           (onTitleChanged)="onViewTitleChanged($event)"
           (onTimeSelected)="onTimeSelected($event)"
           step="30"
         startHour="9"
         endHour="19"
         allDayLabel=""
         class="calendar">
     </calendar>

1 个答案:

答案 0 :(得分:0)

查找一个月内的所有星期日和星期六,然后将这些日期传递给标记为禁用

这是工作链接检查home.ts文件

https://stackblitz.com/edit/ionic-calendar-scheduler-tuuwp3

    <calendar ... [markDisabled]="markDisabled"></calendar>

    markDisabled = (date: Date) => {

        return  (date.getDay()==6 || date.getDay()==0);
    };