Giter VIP home page Giter VIP logo

Comments (10)

vyrotek avatar vyrotek commented on August 15, 2024 35

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.

szabolcssimonyi avatar szabolcssimonyi commented on August 15, 2024 3

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.

craigsh avatar craigsh commented on August 15, 2024 2

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.

garychan8523 avatar garychan8523 commented on August 15, 2024

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.

SvJen avatar SvJen commented on August 15, 2024

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.

ntrannghia avatar ntrannghia commented on August 15, 2024

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.

GuilhermeRabelo avatar GuilhermeRabelo commented on August 15, 2024

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.

LuanPoi avatar LuanPoi commented on August 15, 2024

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.

JulienFr avatar JulienFr commented on August 15, 2024

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.

nite1984 avatar nite1984 commented on August 15, 2024

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)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo 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.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.