Angular 6 compatible Normal Datepciker along with Date range Calender with support of external data view
Demo
https://tanoy009.github.io/ng6-multidatepicker/
Test Case.
In Pipeline will be updated in a while.
Table of contents
About
angular 6 compatible multipurpose calendar with external data integration support and AOT enabled
Installation
Install through npm:
npm install --save ng6-multidatepicker
Then include in your apps module:
import { Component, NgModule } from '@angular/core';
import { Ng6DatepickerModule } from 'ng6-multidatepicker';
@NgModule({
imports: [
Ng6DatepickerModule.forRoot()
]
})
export class MyModule {}
Finally use in one of your apps components:
import { Component } from '@angular/core';
@Component({
template: '<ng6multi-datepicker (dateCallback)="dateCallback($event)"></ng6multi-datepicker>'
})
export class MyComponent {
dateCallback(selectedDate: any) {
}
}
List of settings that can be used to configure the module (all config. are optional):
uiSettings = {
dateDisplayFormat: 'EEEE, MMM d, y',
gridLayout: true,
disableYearMonthDropdown: false,
verticalInputAlignment: false,
disableTooltip: false,
monthToShow: 2,
fontSize: 14,
individualCalendarCellWidth: 48,
individualCalendarCellHeight: 32,
selectedCellColor: '#3dbfd3',
hoverCellColor: '#97f1ff'
};
uiInputSettings = {
fromDateWidth: '50%',
fromDatePlaceholder: 'From Date',
fromDateLabelText: 'Select From Date',
fromDateLabelHide: false,
fromDateMargin: '0',
toDateWidth: '50%',
toDatePlaceholder: 'To Date',
toDateLabelText: 'Select To Date',
toDateLabelHide: false,
toDateMargin: '0'
};
minDate
maxDate
defaultFromDate
defaultToDate
enableRangeSelect = true;
maximumDayInRange = 0;
isExternalDataAvailable = true;
promiseData?: Observable<any>;
@Output()
dateCallback
@Output()
externalDataCallback
NOTE: 'defaultFromDate' and 'defaultToDate' can only be changed after component initialization. 'promiseData' should always return an observable. Please see the below code for better understanding.
import { Component } from '@angular/core';
import { Observable } from 'rxjs';
@Component({
template: '<ng6multi-datepicker [promiseData]="ObservableObj" (externalDataCallback)="externalDataFetchCallback($event)"></ng6multi-datepicker>'
})
export class MyComponent {
public ObservableObj: Observable<any>;
returnFetchedData(data: any) {
this.ObservableObj = new Observable((observer) => {
observer.next(data);
observer.complete();
});
}
externalDataFetchCallback(event: any) {
console.log(event);
data = {
'12/02/2019': {
'key': 'price',
'value': '$500',
'additionalTooltipMsg': 'any html or normal text',
'color': '#E62017'
},
'13/02/2019': {
'key': 'price',
'value': '$200',
'additionalTooltipMsg' : '',
'color': '#E62017'
}
}
this.returnFetchedData(data);
}
}
You may also find it useful to view the demo source.
You can use it with system js as well
'ng6-multidatepicker': 'npm:ng6-multidatepicker/bundles/ng6-multidatepicker.umd.js'
Usage without a module bundler
<script src="node_modules/ng6-multidatepicker/bundles/ng6-multidatepicker.umd.js"></script>
<script>
// everything is exported ng6Calendar namespace
</script>
Documentation
All documentation is auto-generated from the source via compodoc and can be viewed here:
https://tanoy009.github.io/ng6-multidatepicker/docs/
Development
Prepare your environment
- Install Node.js and NPM
- Install local dev dependencies:
npm install
while current directory is this repo
Development server
Run npm start
to start a development server on port 8000 with auto reload + tests.
Testing
Run npm test
to run tests once or npm run test:watch
to continually run tests.
Release
- Bump the version in package.json (once the module hits 1.0 this will become automatic)
npm run release
License
MIT