【发布时间】:2023-03-17 07:48:01
【问题描述】:
我在 Angular 4 中做一个项目,我安装了 ngx 引导程序,日期选择器是英文的。我在 app.module.ts 中插入了以下几行:
import { defineLocale } from 'ngx-bootstrap/chronos';
import { ptBrLocale } from 'ngx-bootstrap/locale';
defineLocale('pt-br', ptBrLocale);
然后我进入了我调用日期选择器的页面组件,我进行了导入并声明:
import { Component, OnInit } from '@angular/core';
import { BsDatepickerConfig, BsLocaleService } from 'ngx-bootstrap/datepicker';
import { listLocales } from 'ngx-bootstrap/chronos';
和
@Component({
selector: 'demo-datepicker-change-locale',
templateUrl: './cancelar-agendamentos-consulta.component.html'
})
export class DemoDatepickerChangeLocaleComponent {
locale = 'pt-br';
locales = listLocales();
constructor(private _localeService: BsLocaleService) {
}
applyLocale(pop: any) {
this._localeService.use(this.locale);
pop.hide();
pop.show();
}
}
它仍然没有工作。我做错了什么?
【问题讨论】:
标签: angular typescript datepicker components ngx-bootstrap