About this package
Daterangepicker for Angular vX.X. Although the name of package is angular 2 it is compatible with angular v4 and v5
It is a fully responsive daterangepicker with or without bootstrap.css. See responsive section below for more details.
This module is strictly intended to work on browsers only and not in node/browserless environments
This is a work in progress and you are always welcome to help me going forward with this project.
Date: 12 Aug 2018
- Added option alwaysOpen to keep the flyout open always 1.1.47
Date: 19 May 2018
- Added option timepicker to enable/disable timepicker in version 1.1.38
- Added option disableBeforeStart to enable/disable dates in right calendar that are before selected from date in version 1.1.39
Date: 5 May 2018
- Added option disabled to enable/disable input box in version 1.1.35
Date: 29 Apr 2018
- Added option position to open flyout on left right or center in version 1.1.30
Date: 28 Apr 2018
- Fixing a small CSS issue in version 1.1.28
Date: 31 Mar 2018
- New option for singleCalendar added in version 1.1.27
Date: 25 Mar 2018
- Made some changes in CSS and responsiveness in version v1.1.26
Date: 23 Mar 2018
- New option for DisplayFormat added in version v1.1.25
Date: 20 Jan 2018
- Module less than version v1.0.10 is no longer supported
$ npm install angular-2-daterangepicker
$ bower install angular-2-daterangepicker
How to make it work for you
Import DaterangepickerModule into your module as following
Currently, very minimum number of options are available but I will keep on developing and adding more and more options
|Option Name||Type||Purpose||Default Value||Possible Values|
|format||string||format that this daterangepicker will use to communicate with your code||"YYYY-MM-DD"||As per momentjs standard formats|
|displayFormat||string||format that will be displayed to end user||Same as format||As per momentjs standard formats|
|startDate||string||Default start date when this components is rendered for first time. Format of this date should be in line with format option's value above||Current Systetm Date||date string in line with format option's value above|
|endDate||string||Default end date when this components is rendered for first time. Format of this date should be in line with format option's value above||Current Systetm Date||date string in line with format option's value above|
|minDate||string||Default minimum date not including this date. End user will not be able select all dates before this date. Format of this date should be in line with format option's value above||null||date string in line with format option's value above|
|maxDate||string||Default maximum date not including this date. End user will not be able select all dates after this date. Format of this date should be in line with format option's value above||null||date string in line with format option's value above|
|inactiveBeforeStart||boolean||Blurs all dates before selected start date. So end user can not select toDate to be before fromDate.||false||true,false|
|autoApply||boolean||Removes apply and cancel buttons and applies as soon as user selects end date||false||true,false|
|showRanges||boolean||Predefined ranges to show to end user. So end user has ready options instead of navingating through calendars.||false||true,false|
|preDefinedRanges||Array of object shown as below.||Custom ranges if you want to define your own ranges. This is useful only if showRanges option is set to true.||see below for more details||see below for more details|
|noDefaultRangeSelected||boolean||This option set the startDate and endDate options to blank on first render.This date range picker sets startDate and endDate to be current system date by dafault if no value is passed to startDate and endDate.||false||true,false|
|singleCalendar||boolean||Use only one calendar. So you do not need another datepicker for single month.||false||true,false|
|position||string||position of the flyout which will open. By default it opens on left edge of input box||'left'||'left','right','center'|
|disabled||boolean||Whether to disable the main input control||false||true,false|
|timePicker||object||Whether to show timepicker||null||Object explained as below|
|disableBeforeStart||boolean||Whether to disable dates that ar before selected start date in right calendar. This option applies to right calendar only||false||true,false|
|alwaysOpen||boolean||Whether to keep the calendars always open. This option removes the main input box where range is shown||false||true,false|
For custom range, Pass options as below. For this you need to pass momentjs objects.
preDefinedRanges:name: 'Day After tomorrow'value:start:end:name: 'This week'value:start:end:
All dates are supposed to be string and in format as you are passing. You can also
class for passing options to the component.
Timepicker options expects an object containing following keys as timepicker options
|Option Name||Type||Purpose||Default Value||Possible Values|
|minuteInterval||(integer)number||The interval by which minutes will increase/decrease when user changes minutes in timepicker||1||anything between 1 to 59. If you supply value greater or equal 60 then that value mod 60 is taken as actual value|
Subscribe to rangeSelected event as
start: 'moment object representing start date selected by user'end: 'moment object representing end date selected by user'
and if you have set singleCalendar to true then the event listener will receive following
start: 'moment object representing date selected by user'
How pass options to the component
The input box automatically takes class of the date-range-picker tag
moment.js version greater than 2.17.1
moment-range.js version 2.2.0
also you should have installed @types/node or see here for more information. I suggest installing all the dependencies before this module
If you are using bootstrap.css then just include the following styling in your code if you do not want to include whole bootstrap.css then include this css in your code.
Please let me know if you are facing any issues here
Want to contribute. You are welcome!!! :)
- Fork this repo
- npm install
- Copy all files from this gist to your local folder. And do not add them to git index otherwise they will appear in your pull requests.
- run "npm install -g typescript typescript-formatter lite-server concurrently rimraf"
- run "npm start"
- open browser at http://localhost:3000/
- You are all set.
- Add features. Fix issues. Open Pull requests.
- Remember not to include files from gist in your pull requests