我使用来自ngx-bootstrap的时间选择器,如下所示:
<timepicker [(ngModel)]="startDateTime" name="startTimes" #startTime="ngModel" required [showMeridian]="true"></timepicker> 尝试让区域设置基于登录用户的'de' (德语)和'ja' (日语),如下所示:
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
我做错了什么?
发布于 2018-05-14 18:01:11
我认为你应该在模块中添加这一部分
// imports
import { defineLocale, jaLocale } from 'ngx-bootstrap';
defineLocale('ja', jaLocale);
// @NgModule(...)https://stackoverflow.com/questions/50013675
复制相似问题