|  | 
|  | 1 | + | 
|  | 2 | +# Angular 2 / 4 DateTime Picker | 
|  | 3 | + | 
|  | 4 | +# [Documentation](http://cuppalabs.github.io/components/datepicker) | [Demos / Examples](https://cuppalabs.github.io/angular2-datetimepicker). | 
|  | 5 | + | 
|  | 6 | +### Overview  | 
|  | 7 | + | 
|  | 8 | +Angular 2 DateTimepicker is a cool responsive DateTimepicker component for Web and Mobile. It is Mobile friendly and light weight. Developed by [Cuppa Labs](http://www.cuppalabs.com). | 
|  | 9 | + | 
|  | 10 | +### Getting Started | 
|  | 11 | +To get started with using the multiselect dropdown component, follow the below steps. It’s easy to integrate and just a matter of minutes. | 
|  | 12 | + | 
|  | 13 | +### Installation | 
|  | 14 | +- The datetimepicker package is published on the [npm](https://www.npmjs.com/package/angular2-datetimepicker) Registry.  | 
|  | 15 | +- Install the package with [npm](https://www.npmjs.com):  | 
|  | 16 | + | 
|  | 17 | +```js | 
|  | 18 | +npm install angular2-datetimepicker | 
|  | 19 | +``` | 
|  | 20 | + | 
|  | 21 | +### Usage | 
|  | 22 | + | 
|  | 23 | +Import `AngularDateTimePickerModule` into your `AppModule` | 
|  | 24 | + | 
|  | 25 | +```js | 
|  | 26 | +import { AngularDateTimePickerModule } from 'angular2-datetimepicker'; | 
|  | 27 | + | 
|  | 28 | +@NgModule({ | 
|  | 29 | + // ... | 
|  | 30 | + imports: [ | 
|  | 31 | + AngularDateTimePickerModule, | 
|  | 32 | + ] | 
|  | 33 | + // ... | 
|  | 34 | +}) | 
|  | 35 | + | 
|  | 36 | +``` | 
|  | 37 | +Declare the component data variables and options in your component where you want to consume the dropdown component. | 
|  | 38 | + | 
|  | 39 | +```js  | 
|  | 40 | +import { Component, OnInit } from '@angular/core'; | 
|  | 41 | + | 
|  | 42 | +export class AppComponent implements OnInit { | 
|  | 43 | +  | 
|  | 44 | +date: Date = new Date(); | 
|  | 45 | +settings = { | 
|  | 46 | +bigBanner: true, | 
|  | 47 | +timePicker: false, | 
|  | 48 | +format: 'dd-MM-yyyy', | 
|  | 49 | +defaultOpen: true | 
|  | 50 | +} | 
|  | 51 | +constructor(){} | 
|  | 52 | + ngOnInit(){ | 
|  | 53 | +  | 
|  | 54 | + } | 
|  | 55 | +} | 
|  | 56 | + | 
|  | 57 | +``` | 
|  | 58 | + | 
|  | 59 | +Add the following component tag in the template where your want to place the datepicker | 
|  | 60 | + | 
|  | 61 | +```html | 
|  | 62 | + | 
|  | 63 | +<angular2-date-picker [(ngModel)]="date" [settings]="settings"></angular2-date-picker> | 
|  | 64 | + | 
|  | 65 | +``` | 
|  | 66 | + | 
|  | 67 | + | 
|  | 68 | +### Settings | 
|  | 69 | + | 
|  | 70 | +Following `settings` object properties can be used to configure the component. | 
|  | 71 | + | 
|  | 72 | +|Property|Type|Default|Description| | 
|  | 73 | +|:--- |:--- |:--- |:--- | | 
|  | 74 | +|format|String|dd-MMM-yyyy hh:mm a|Date format of the selected date.| | 
|  | 75 | +|bigBanner|Boolean|true| The banner section to show the date details. | | 
|  | 76 | +|defaultOpen|Boolean|false|To open the datepicker popover on load. Default is set to false.| | 
|  | 77 | +|timePicker|Boolean|false|Enable time picker feature.| | 
|  | 78 | +|closeOnSelect|Boolean|true|to close the popover on date select or on click of done button.| | 
|  | 79 | + | 
|  | 80 | + | 
|  | 81 | +## Callback Methods | 
|  | 82 | + | 
|  | 83 | +- `onDateSelect` | 
|  | 84 | + | 
|  | 85 | +Define a callback method to be called on select of the date. | 
|  | 86 | + | 
|  | 87 | +```html | 
|  | 88 | +  | 
|  | 89 | + <angular2-date-picker (onDateSelect)="onDateSelect($event)"  | 
|  | 90 | +[(ngModel)]="date"  | 
|  | 91 | +[settings]="settings" > | 
|  | 92 | + </angular2-date-picker> | 
|  | 93 | + | 
|  | 94 | +``` | 
|  | 95 | +## Date Formats Support | 
|  | 96 | + | 
|  | 97 | +format string can be composed of the following elements: | 
|  | 98 | + | 
|  | 99 | +- 'yyyy': 4 digit representation of year (e.g. AD 1 => 0001, AD 2010 => 2010) | 
|  | 100 | +- 'yy': 2 digit representation of year, padded (00-99). (e.g. AD 2001 => 01, AD 2010 => 10) | 
|  | 101 | +- 'y': 1 digit representation of year, e.g. (AD 1 => 1, AD 199 => 199) | 
|  | 102 | +- 'MMMM': Month in year (January-December) | 
|  | 103 | +- 'MMM': Month in year (Jan-Dec) | 
|  | 104 | +- 'MM': Month in year, padded (01-12) | 
|  | 105 | +- 'M': Month in year (1-12) | 
|  | 106 | +- 'LLLL': Stand-alone month in year (January-December) | 
|  | 107 | +- 'dd': Day in month, padded (01-31) | 
|  | 108 | +- 'd': Day in month (1-31) | 
|  | 109 | +- 'EEEE': Day in Week,(Sunday-Saturday) | 
|  | 110 | +- 'EEE': Day in Week, (Sun-Sat) | 
|  | 111 | +- 'HH': Hour in day, padded (00-23) | 
|  | 112 | +- 'H': Hour in day (0-23) | 
|  | 113 | +- 'hh': Hour in AM/PM, padded (01-12) | 
|  | 114 | +- 'h': Hour in AM/PM, (1-12) | 
|  | 115 | +- 'mm': Minute in hour, padded (00-59) | 
|  | 116 | +- 'm': Minute in hour (0-59) | 
|  | 117 | +- 'ss': Second in minute, padded (00-59) | 
|  | 118 | +- 's': Second in minute (0-59) | 
|  | 119 | +- 'sss': Millisecond in second, padded (000-999) | 
|  | 120 | +- 'a': AM/PM marker | 
|  | 121 | +- 'Z': 4 digit (+sign) representation of the timezone offset (-1200-+1200) | 
|  | 122 | +- 'ww': Week of year, padded (00-53). Week 01 is the week with the first Thursday of the year | 
|  | 123 | +- 'w': Week of year (0-53). Week 1 is the week with the first Thursday of the year | 
|  | 124 | +- 'G', 'GG', 'GGG': The abbreviated form of the era string (e.g. 'AD') | 
|  | 125 | +- 'GGGG': The long form of the era string (e.g. 'Anno Domini') | 
|  | 126 | + | 
|  | 127 | +format string can also be one of the following predefined localizable formats: | 
|  | 128 | + | 
|  | 129 | +- 'medium': equivalent to 'MMM d, y h:mm:ss a' for en_US locale (e.g. Sep 3, 2010 12:05:08 PM) | 
|  | 130 | + | 
|  | 131 | +- 'short': equivalent to 'M/d/yy h:mm a' for en_US locale (e.g. 9/3/10 12:05 PM) | 
|  | 132 | +- 'fullDate': equivalent to 'EEEE, MMMM d, y' for en_US locale (e.g. Friday, September 3, 2010) | 
|  | 133 | +- 'longDate': equivalent to 'MMMM d, y' for en_US locale (e.g. September 3, 2010) | 
|  | 134 | +- 'mediumDate': equivalent to 'MMM d, y' for en_US locale (e.g. Sep 3, 2010) | 
|  | 135 | +- 'shortDate': equivalent to 'M/d/yy' for en_US locale (e.g. 9/3/10) | 
|  | 136 | +- 'mediumTime': equivalent to 'h:mm:ss a' for en_US locale (e.g. 12:05:08 PM) | 
|  | 137 | +- 'shortTime': equivalent to 'h:mm a' for en_US locale (e.g. 12:05 PM) | 
|  | 138 | + | 
|  | 139 | +## Run locally | 
|  | 140 | +- Clone the repository or downlod the .zip,.tar files. | 
|  | 141 | +- Run `npm install` | 
|  | 142 | +- Run `ng serve` for a dev server | 
|  | 143 | +- Navigate to `http://localhost:4200/` | 
|  | 144 | + | 
|  | 145 | +## License | 
|  | 146 | +MIT License. | 
|  | 147 | + | 
|  | 148 | +## Credits | 
|  | 149 | +Thanks to Font Awesome and Moment.js for the libraries. | 
|  | 150 | + | 
|  | 151 | +## Author | 
|  | 152 | +Pradeep Kumar Terli | 
0 commit comments