Comments (10)
Agreed. For those stumbling along trying to get this to work with Moment here are the critical pieces barely mentioned.
import { NgxMatMomentModule, NgxMatMomentAdapter, NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular-material-components/moment-adapter';
import { NgxMatDatetimePickerModule, NgxMatTimepickerModule, NGX_MAT_DATE_FORMATS, NgxMatDateAdapter } from '@angular-material-components/datetime-picker';
export const CUSTOM_MOMENT_FORMATS = {
parse: {
dateInput: "l, LT"
},
display: {
dateInput: "l, LT",
monthYearLabel: "MMM YYYY",
dateA11yLabel: "LL",
monthYearA11yLabel: "MMMM YYYY"
}
};
@NgModule({
imports: [
NgxMatMomentModule,
NgxMatDatetimePickerModule,
NgxMatTimepickerModule,
... ],
providers: [
{ provide: NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } },
{ provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_MOMENT_FORMATS },
{ provide: NgxMatDateAdapter, useClass: NgxMatMomentAdapter },
... ]
})
It's a great and flexible component! It could really use some thorough documentation.
from angular-material-components.
Agreed. For those stumbling along trying to get this to work with Moment here are the critical pieces barely mentioned.
import { NgxMatMomentModule, NgxMatMomentAdapter, NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular-material-components/moment-adapter'; import { NgxMatDatetimePickerModule, NgxMatTimepickerModule, NGX_MAT_DATE_FORMATS, NgxMatDateAdapter } from '@angular-material-components/datetime-picker'; export const CUSTOM_MOMENT_FORMATS = { parse: { dateInput: "l, LT" }, display: { dateInput: "l, LT", monthYearLabel: "MMM YYYY", dateA11yLabel: "LL", monthYearA11yLabel: "MMMM YYYY" } }; @NgModule({ imports: [ NgxMatMomentModule, NgxMatDatetimePickerModule, NgxMatTimepickerModule, ... ], providers: [ { provide: NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } }, { provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_MOMENT_FORMATS }, { provide: NgxMatDateAdapter, useClass: NgxMatMomentAdapter }, ... ] })
It's a great and flexible component! It could really use some thorough documentation.
Thank you!
from angular-material-components.
For anybody else who gets stuck on this, I was wanting to use the time picker only.
I got it to work minimally with the following:
import {
NgxMatTimepickerModule,
NgxMatDateAdapter,
NgxMatNativeDateAdapter
} from '@angular-material-components/datetime-picker';
@NgModule({
imports: [
NgxMatTimepickerModule,
providers: [
{ provide: NgxMatDateAdapter, useClass: NgxMatNativeDateAdapter },
Hope that helps somebody.
I like this library but the documentation could be better. And the StackBlitz example has errors!
from angular-material-components.
Agreed. For those stumbling along trying to get this to work with Moment here are the critical pieces barely mentioned.
import { NgxMatMomentModule, NgxMatMomentAdapter, NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular-material-components/moment-adapter'; import { NgxMatDatetimePickerModule, NgxMatTimepickerModule, NGX_MAT_DATE_FORMATS, NgxMatDateAdapter } from '@angular-material-components/datetime-picker'; export const CUSTOM_MOMENT_FORMATS = { parse: { dateInput: "l, LT" }, display: { dateInput: "l, LT", monthYearLabel: "MMM YYYY", dateA11yLabel: "LL", monthYearA11yLabel: "MMMM YYYY" } }; @NgModule({ imports: [ NgxMatMomentModule, NgxMatDatetimePickerModule, NgxMatTimepickerModule, ... ], providers: [ { provide: NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } }, { provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_MOMENT_FORMATS }, { provide: NgxMatDateAdapter, useClass: NgxMatMomentAdapter }, ... ] })
It's a great and flexible component! It could really use some thorough documentation.
Thank you!
I spent days and hours on this, thanks !
from angular-material-components.
Agreed. For those stumbling along trying to get this to work with Moment here are the critical pieces barely mentioned.
import { NgxMatMomentModule, NgxMatMomentAdapter, NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular-material-components/moment-adapter'; import { NgxMatDatetimePickerModule, NgxMatTimepickerModule, NGX_MAT_DATE_FORMATS, NgxMatDateAdapter } from '@angular-material-components/datetime-picker'; export const CUSTOM_MOMENT_FORMATS = { parse: { dateInput: "l, LT" }, display: { dateInput: "l, LT", monthYearLabel: "MMM YYYY", dateA11yLabel: "LL", monthYearA11yLabel: "MMMM YYYY" } }; @NgModule({ imports: [ NgxMatMomentModule, NgxMatDatetimePickerModule, NgxMatTimepickerModule, ... ], providers: [ { provide: NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } }, { provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_MOMENT_FORMATS }, { provide: NgxMatDateAdapter, useClass: NgxMatMomentAdapter }, ... ] })
It's a great and flexible component! It could really use some thorough documentation.
Thank you so much!!! It saved several hours/days of my life!!!
from angular-material-components.
Agreed. For those stumbling along trying to get this to work with Moment here are the critical pieces barely mentioned.
import { NgxMatMomentModule, NgxMatMomentAdapter, NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular-material-components/moment-adapter'; import { NgxMatDatetimePickerModule, NgxMatTimepickerModule, NGX_MAT_DATE_FORMATS, NgxMatDateAdapter } from '@angular-material-components/datetime-picker'; export const CUSTOM_MOMENT_FORMATS = { parse: { dateInput: "l, LT" }, display: { dateInput: "l, LT", monthYearLabel: "MMM YYYY", dateA11yLabel: "LL", monthYearA11yLabel: "MMMM YYYY" } }; @NgModule({ imports: [ NgxMatMomentModule, NgxMatDatetimePickerModule, NgxMatTimepickerModule, ... ], providers: [ { provide: NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } }, { provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_MOMENT_FORMATS }, { provide: NgxMatDateAdapter, useClass: NgxMatMomentAdapter }, ... ] })
It's a great and flexible component! It could really use some thorough documentation.
Thank you so much!!! It saved several hours/days of my life!!!
from angular-material-components.
Agreed. For those stumbling along trying to get this to work with Moment here are the critical pieces barely mentioned.
import { NgxMatMomentModule, NgxMatMomentAdapter, NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular-material-components/moment-adapter'; import { NgxMatDatetimePickerModule, NgxMatTimepickerModule, NGX_MAT_DATE_FORMATS, NgxMatDateAdapter } from '@angular-material-components/datetime-picker'; export const CUSTOM_MOMENT_FORMATS = { parse: { dateInput: "l, LT" }, display: { dateInput: "l, LT", monthYearLabel: "MMM YYYY", dateA11yLabel: "LL", monthYearA11yLabel: "MMMM YYYY" } }; @NgModule({ imports: [ NgxMatMomentModule, NgxMatDatetimePickerModule, NgxMatTimepickerModule, ... ], providers: [ { provide: NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } }, { provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_MOMENT_FORMATS }, { provide: NgxMatDateAdapter, useClass: NgxMatMomentAdapter }, ... ] })
It's a great and flexible component! It could really use some thorough documentation.
I'm very grateful, thank you for making my life easier
from angular-material-components.
For anybody else who gets stuck on this, I was wanting to use the time picker only.
I got it to work minimally with the following:
import { NgxMatTimepickerModule, NgxMatDateAdapter, NgxMatNativeDateAdapter } from '@angular-material-components/datetime-picker';
@NgModule({ imports: [ NgxMatTimepickerModule,
providers: [ { provide: NgxMatDateAdapter, useClass: NgxMatNativeDateAdapter },
Hope that helps somebody.
I like this library but the documentation could be better. And the StackBlitz example has errors!
Solved my problem, thank you very much!
from angular-material-components.
Using
@angular-material-components/datetime-picker": "^7.0.1",
@angular-material-components/moment-adapter": "^7.0.0"
I had to put NgxMatNativeDateModule before NgxMatMomentModule to get the custom date format working.
NgxMatNativeDateModule, // must be before NgxMatMomentModule
NgxMatMomentModule,
NgxMatDatetimePickerModule,
NgxMatTimepickerModule,
from angular-material-components.
Agreed. For those stumbling along trying to get this to work with Moment here are the critical pieces barely mentioned.
import { NgxMatMomentModule, NgxMatMomentAdapter, NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS } from '@angular-material-components/moment-adapter'; import { NgxMatDatetimePickerModule, NgxMatTimepickerModule, NGX_MAT_DATE_FORMATS, NgxMatDateAdapter } from '@angular-material-components/datetime-picker'; export const CUSTOM_MOMENT_FORMATS = { parse: { dateInput: "l, LT" }, display: { dateInput: "l, LT", monthYearLabel: "MMM YYYY", dateA11yLabel: "LL", monthYearA11yLabel: "MMMM YYYY" } }; @NgModule({ imports: [ NgxMatMomentModule, NgxMatDatetimePickerModule, NgxMatTimepickerModule, ... ], providers: [ { provide: NGX_MAT_MOMENT_DATE_ADAPTER_OPTIONS, useValue: { useUtc: true } }, { provide: NGX_MAT_DATE_FORMATS, useValue: CUSTOM_MOMENT_FORMATS }, { provide: NgxMatDateAdapter, useClass: NgxMatMomentAdapter }, ... ] })
It's a great and flexible component! It could really use some thorough documentation.
Thanks, I wish the official doc was this clear.
from angular-material-components.
Related Issues (20)
- 'ngx-mat-datepicker-actions' is not a known element
- Internationalization issue - first day of week
- custom action button not working
- Cannot use datetime-picker with Angular 15 and Angular Material 14
- Angular 17 compatibility HOT 14
- [Angular 16] Angular 16.2.1. breaks the styling of the datetimepicker component HOT 2
- more than 2 datetime picker in one page which is load dynamically & Not able to change the format
- [Angular 10] Keyboard navigation broken
- About the ngx-matdate-time-picker
- Switching between the years is very slow on the date picker version 8 HOT 3
- Spinner icons are not loading HOT 2
- Optional HEX Color Input field
- want to have keyboard toggle in dates HOT 1
- ngx-mat-datetime-picker is improperly formatted in angular 16 HOT 3
- Datepicker design breaks Angular 13 HOT 2
- angular upgrade V16 to V17 HOT 1
- No option for language change
- No Arabic digits in the time field
- latest version is not supported with Angular 17. HOT 1
- latest version is not supported with Angular 17 HOT 2
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from angular-material-components.