CuppaLabs / angular2-datetimepicker

Angular 2 and 4 datetime picker component
https://cuppalabs.github.io/angular2-datetimepicker
41 stars 50 forks source link
angular2 angular2-datepicker angular4 datetimepicker

Angular 2 / 4 DateTime Picker

Documentation | Demos / Examples.

Overview

Angular 2 DateTimepicker is a cool responsive DateTimepicker component for Web and Mobile. It is Mobile friendly and light weight. Developed by Cuppa Labs.

Getting Started

To get started with using the multiselect dropdown component, follow the below steps. It’s easy to integrate and just a matter of minutes.

Installation

    npm install angular2-datetimepicker

Usage

Import AngularDateTimePickerModule into your AppModule

import { AngularDateTimePickerModule } from 'angular2-datetimepicker';

@NgModule({
  // ...
  imports: [
    AngularDateTimePickerModule,
  ]
  // ...
})

Declare the component data variables and options in your component where you want to consume the dropdown component.

import { Component, OnInit } from '@angular/core';

export class AppComponent implements OnInit {

    date: Date = new Date();
    settings = {
        bigBanner: true,
        timePicker: false,
        format: 'dd-MM-yyyy',
        defaultOpen: true
    }
    constructor(){}
    ngOnInit(){

    }
}

Add the following component tag in the template where your want to place the datepicker


<angular2-date-picker [(ngModel)]="date" [settings]="settings"></angular2-date-picker>

Settings

Following settings object properties can be used to configure the component.

Property Type Default Description
format String dd-MMM-yyyy hh:mm a Date format of the selected date.
bigBanner Boolean true The banner section to show the date details.
defaultOpen Boolean false To open the datepicker popover on load. Default is set to false.
timePicker Boolean false Enable time picker feature.
closeOnSelect Boolean true to close the popover on date select or on click of done button.

Callback Methods

Define a callback method to be called on select of the date.


  <angular2-date-picker (onDateSelect)="onDateSelect($event)" 
            [(ngModel)]="date" 
            [settings]="settings" >
  </angular2-date-picker>

Date Formats Support

format string can be composed of the following elements:

format string can also be one of the following predefined localizable formats:

Run locally

License

MIT License.

Credits

Thanks to Font Awesome and Moment.js for the libraries.

Author

Pradeep Kumar Terli