ngx-multiple-dates v18.1.0
Angular Multiple Dates
Multiple dates picker based on Angular Material.

Demo
Installation
- Install dependency:
npm install --save ngx-multiple-dates- Include
NgxMultipleDatesModuleto your module:
import { NgModule } from '@angular/core';
import { BrowserModule } from '@angular/platform-browser';
import { BrowserAnimationsModule } from '@angular/platform-browser/animations';
import { MatNativeDateModule } from '@angular/material/core';
import { MatDatepickerModule } from '@angular/material/datepicker';
import { MatIconModule } from '@angular/material/icon';
import { NgxMultipleDatesModule } from 'ngx-multiple-dates'; // module import
@NgModule({
imports: [
BrowserModule,
BrowserAnimationsModule,
MatNativeDateModule,
MatDatepickerModule,
MatIconModule,
NgxMultipleDatesModule // import to Angular
// ...
],
// ...
})
export class AppModule { }- Styles:
- Add one of the prebuilt themes to
angular.jsonor your styles file:
@import 'ngx-multiple-dates/prebuilt-themes/indigo-pink.css';- Or you can use custom SCSS theme:
@import '~@angular/material/theming';
@import '~ngx-multiple-dates/theming'; // import library theme
@include mat-core();
// Palette
$primary: mat-palette($mat-indigo);
$accent: mat-palette($mat-pink);
$theme: mat-light-theme($primary, $accent); // theme
@include angular-material-theme($theme); // apply Angular Material styles
@include ngx-multiple-dates-theme($theme); // apply Angular Multiple Dates styles
// ...Available pre-built themes:
deeppurple-amber.cssindigo-pink.csspink-bluegrey.csspurple-green.css
Dependencies
- Angular
- Angular CDK
- Angular Material
- RxJs
Examples
<mat-form-field>
<ngx-multiple-dates [matDatepicker]="picker" placeholder="Excluded Dates" name="excludedDates"
[(ngModel)]="model">
</ngx-multiple-dates>
<mat-datepicker-toggle matPrefix [for]="picker"></mat-datepicker-toggle>
<mat-datepicker #picker></mat-datepicker>
</mat-form-field>API reference
MultipleDatesComponent<D = Date>
Selector: ngx-multiple-dates
Exported as: ngxMultipleDates
Properties
| Name | Description |
|---|---|
| Input | |
@Input()value: D \| null | The value of the ngx-multiple-dates control. |
@Input()matDatepicker: MatDatepicker<D> | The datepicker that this ngx-multiple-dates element is associated with. |
@Input()color: ThemePalette | Theme color palette for the component. |
@Input()placeholder: string | Placeholder to be shown if no value has been selected. |
@Input()required: boolean | Whether the component is required. |
@Input()disabled: boolean | Whether the component is disabled. |
@Input()matDatepickerFilter: (date: D) => boolean | Function that can be used to filter out dates within the datepicker. |
@Input()max: D \| null | The maximum valid date. |
@Input()min: D \| null | The minimum valid date. |
@Input()id: string | Unique id of the element. |
@Input()errorStateMatcher: ErrorStateMatcher | An object used to control when error messages are shown. Color palette to use on the datepicker's calendar. |
| Output | |
@Output()dateChange: EventEmitter<MatDatepickerInputEvent<D>> | Emits when a change event is fired on this ngx-multiple-dates element. |
| Properties | |
resetModel: Date | Model used to reset datepicker selected value, so unselect just selectad date will be possible. |
closeOnSelected: boolean | Whether datepicker should be closed on date selected, or opened to select more dates. |
empty: boolean | Whether the select has a value. |
shouldLabelFloat: boolean | Whether the MatFormField label should try to float. |
focused: boolean | Whether ngx-multiple-dates element has focus. |
errorState: boolean | Whether the control is in an error state. |
stateChanges: Observable<void> | Stream that emits whenever the state of the control changes such that the parent MatFormField needs to run change detection. |
ngControl: NgControl | Form control to manage component. |
controlType: 'ngx-multiple-dates' | A name for this control that can be used by mat-form-field. |
Methods
focusFocuses thengx-multiple-dateselement.blurUsed to leave focus from thengx-multiple-dateselement.setDescribedByIdsSets the list of element IDs that currently describe this control.
| Parameters | |
|---|---|
ids: string[] | Ids to set. |
onContainerClickHandles a click on the control's container.validatePerforms synchronous validation for the control.
| Parameters | |
|---|---|
control: AbstractControl | The control to validate against. |
| Returns | |
ValidationErrors \| null | A map of validation errors if validation fails, otherwise null. |
dateClassFunction used to add CSS classes to selected dates.
| Parameters | |
|---|---|
date: D | Date to check if classes should be applied. |
| Returns | |
MatCalendarCellCssClasses | CSS classes to apply. |
dateChangedFires when a change event is fired on the datepicker<input />.
| Parameters | |
|---|---|
event: MatDatepickerInputEvent<D> | Change event. |
removeRemoves selected chip from the list.
| Parameters | |
|---|---|
date: D | Value to remove. |
Build
Run npm run build to build the project. The build artifacts will be stored in the dist/ directory. Use the --prod flag for a production build.
Development server
Run npm start for a dev server. Navigate to http://localhost:4200/. The app will automatically reload if you change any of the source files.
9 months ago
1 year ago
2 years ago
2 years ago
2 years ago
2 years ago
3 years ago
3 years ago
3 years ago
3 years ago
4 years ago
4 years ago
4 years ago
4 years ago
4 years ago
5 years ago
6 years ago
6 years ago
6 years ago
6 years ago