Code Monkey home page Code Monkey logo

easy-ionic2-calendar's Introduction

An easy calendar for your Ionic 2 App

Demo:

Live Demo

How to use:

Place the following in the desired page:

<ion-calendar
        (onChange)="onChange($event)"
        [events]="myEvents"
        (onEventClicked)="eventClicked($event)"
        [useSwipe]="true"
        [todayText]="Today"
        [showEventsList]="true"
        [disablePastDates]="false"
        [weekDaysToDisable]="[0,6]"
        [daysToDisable]="[10,11,12]"
        [inputDate]="myDate">
</ion-calendar>

Read about the options below.

Installation process:

  • Clone the project and copy the ion-calendar folder to your project's components folder (src/components).

  • Import the component on your app.module.ts:

    import { IonCalendarComponent } from '../components/ion-calendar/ion-calendar';
    
  • Insert it on the declarations array:

    declarations: [
        MyApp,
        HomePage,
        IonCalendarComponent
      ],
    
  • Add <ion-calendar></ion-calendar> in your desired view.

  • Set the options and add the callback functions to your controller.

Options:

  • (onChange)="yourOnDateChangeCallback($event)"
    • This callback is triggered everytime the current selected date is changed.
    • It passes the new date as the parameter.
  • (onEventClicked)="yourOnEventClickedCallback($event)"
    • This callback is triggered everytime an event is clicked (from the list below the calendar).
    • It passes the clicked event as the parameter.
  • [events]="yourEventsArray"
    • yourEventsArray should be an array of objects with the following properties:
      • starts: Date object representing the date and time that the events starts.
      • ends: Date object representing the date and time that the events ends.
      • title: String with the title to be shown in the events list.
  • [showEventsList]="true"
    • Wheter or not to show the events list on the bottom of the calendar
  • [disablePastDates]="false"
    • Wheter or not to show past dates as disabled (disables user click on those dates)
  • [weekDaysToDisable]="[0,6]"
    • You can use this to disable certain weekdays, in this example we are disabling Sundays (0) and Saturdays (6). Users will not be able to click these days.
  • [daysToDisable]="[10,11,12]"
    • You can use this to disable certain days of the month. In this example, days 10, 11 and 12 of the current month will be disabled.
  • [useSwipe]="false"
    • You can use this to prevent swiping through the months
  • [todayText]="Today"
    • You can use this to translate the today's button content to other languages
  • [inputDate]="yourDateObject"
    • Date object you can use to set the initial date or to set the selected date programmatically.
      • When you want to set the selected date programmatically, remember to always create a new reference(a new Date object). Example:

        this.yourDateObject.setDate(5); /* This will NOT work and the view is not going to update correctly */
        
        var tmpDate = new Date();
        tmpDate.setDate(5);
        this.yourDateObject = tmpDate; /* This will work and date will be updated on the calendar view */
        

easy-ionic2-calendar's People

Contributors

alexandretok avatar

Watchers

 avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.