Closed juanjosesanchezesteban closed 3 years ago
Hello,
I can't get the library to recognize my locale in Spanish. It takes the default option which is the name of the months and days in English.
My code is the following:
`import { Component, OnInit } from '@angular/core'; import { DatePickerOptions, NgxDatePickerComponent } from '@ngx-tiny/date-picker';
import { environment } from '../../../environments/environment'; import { es } from 'date-fns/locale'
@Component({ selector: 'app-componentes', templateUrl: './componentes.component.html', styleUrls: ['./componentes.component.css'] }) export class ComponentesComponent implements OnInit {
singleDate: Date = new Date(); dateInstanceSingle: NgxDatePickerComponent; datePickerOptions: DatePickerOptions = { locale: es, displayFormat: 'dd/MM/yyyy', barTitleFormat: 'MMMM yyyy', firstCalendarDay: 1 };
constructor() { }
ngOnInit(): void { }
onChangeSingle(value: Date): void { this.singleDate = value; console.log(this.singleDate); }
} `
`
Componentes
<input class="form-control" placeholder="Select date" [ngxDatePicker]="dateInstanceSingle" [value]="singleDate" (valueChange)="onChangeSingle($event)"> <ngx-date-picker #dateInstanceSingle [options]="datePickerOptions">
You need to wrap the es inside a object
public datePickerOptions: DatePickerOptions = { locale: {locale: de}, // ... }
It works, thank you very much Andrea.
Hello,
I can't get the library to recognize my locale in Spanish. It takes the default option which is the name of the months and days in English.
My code is the following:
`import { Component, OnInit } from '@angular/core'; import { DatePickerOptions, NgxDatePickerComponent } from '@ngx-tiny/date-picker';
import { environment } from '../../../environments/environment'; import { es } from 'date-fns/locale'
@Component({ selector: 'app-componentes', templateUrl: './componentes.component.html', styleUrls: ['./componentes.component.css'] }) export class ComponentesComponent implements OnInit {
singleDate: Date = new Date(); dateInstanceSingle: NgxDatePickerComponent; datePickerOptions: DatePickerOptions = { locale: es, displayFormat: 'dd/MM/yyyy', barTitleFormat: 'MMMM yyyy', firstCalendarDay: 1 };
constructor() { }
ngOnInit(): void { }
onChangeSingle(value: Date): void { this.singleDate = value; console.log(this.singleDate); }
} `
`
Componentes
<input class="form-control" placeholder="Select date" [ngxDatePicker]="dateInstanceSingle" [value]="singleDate" (valueChange)="onChangeSingle($event)"> <ngx-date-picker #dateInstanceSingle [options]="datePickerOptions">