estou enfrentando problemas no Angular. Estou usando o angular material para alguns /componentes e eu estou usando o datepicker. O meu date locale já é 'pt', aparece até o nome dos meses em portugues e tal. Mas quando eu digito no input 11/08/1997 e clico fora do input, ele muda para 08/11/1997. Já tentei de tudo aqui mas não consegui.
1 Resposta
Conseguir resolver colocando isso no meu modulo:
import { MatNativeDateModule, MAT_DATE_FORMATS } from '@angular/material';
import { MomentDateModule } from '@angular/material-moment-adapter';
...
providers: [
{
provide: MAT_DATE_FORMATS,
useValue: {
parse: {
dateInput: ['l', 'LL'],
},
display: {
dateInput: 'L',
monthYearLabel: 'MMM YYYY',
dateA11yLabel: 'LL',
monthYearA11yLabel: 'MMMM YYYY',
},
},
}
]
e no meu componente do input
import { DateAdapter } from '@angular/material';
ngOnInit() {
this.dateAdapter.setLocale('pt-br');
}