我正在使用ngx-bootstrap的timepicker,如下所示:
<timepicker [(ngModel)]="startDateTime" name="startTimes" #startTime="ngModel" required [showMeridian]="true"></timepicker>
根据已登录的用户,尝试让语言环境适用于'de'
(Deutsche)和'ja'
(Japaneese):
app.module.ts:
import {TimepickerModule, BsLocaleService} from 'ngx-bootstrap';
@NgModule({
imports: [
TimepickerModule.forRoot()
],
declarations: [
],
providers: [
BsLocaleService
]
})
my.component.ts:
import {Component, OnInit, Inject, ViewChild, SimpleChange, SimpleChanges} from '@angular/core';
import {TimepickerModule, BsLocaleService} from 'ngx-bootstrap';
import {listLocales} from 'ngx-bootstrap';
import {deLocale} from 'ngx-bootstrap';
import {jaLocale} from 'ngx-bootstrap';
@Component({
selector: 'my-component',
templateUrl: './my-component.html',
styleUrls: ['./my-component.less']
})
export class MyComponent implements OnInit {
locale = 'ja'; //hardcoded for testing
locales = listLocales();
startDateTime = new Date();
constructor(private _localeService: BsLocaleService) {
this._localeService.use(this.locale);
}
这不适用于区域设置,timepicker
的功能正常工作。我对此很陌生,网站上的文档没有关于timepicker
语言环境的任何内容。我通过查看datepicker
区域设置:https://valor-software.com/ngx-bootstrap/#/datepicker#locales
我做错了什么?
答案 0 :(得分:0)
我认为你应该在模块中添加这篇文章
// imports
import { defineLocale, jaLocale } from 'ngx-bootstrap';
defineLocale('ja', jaLocale);
// @NgModule(...)