繁体   English   中英

角度5:ngx-bootstrap timepicker语言环境

[英]angular 5: ngx-bootstrap timepicker locale

我正在像这样从ngx-bootstrap使用timepicker:

 <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 ,该站点上的文档没有关于timepicker语言环境的任何信息。 我通过查看datepicker区域设置实现了这一点: https : datepicker

我究竟做错了什么 ?

我认为您应该在模块中添加此部分

// imports

import { defineLocale, jaLocale } from 'ngx-bootstrap';

defineLocale('ja', jaLocale);

// @NgModule(...)

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM