首页
学习
活动
专区
圈层
工具
发布
社区首页 >问答首页 >angular 5: ngx-bootstrap时间选择器区域设置

angular 5: ngx-bootstrap时间选择器区域设置
EN

Stack Overflow用户
提问于 2018-04-25 11:34:49
回答 1查看 3.3K关注 0票数 1

我使用来自ngx-bootstrap的时间选择器,如下所示:

代码语言:javascript
复制
 <timepicker [(ngModel)]="startDateTime" name="startTimes" #startTime="ngModel" required [showMeridian]="true"></timepicker>                                                          

尝试让区域设置基于登录用户的'de' (德语)和'ja' (日语),如下所示:

app.module.ts:

代码语言:javascript
复制
import {TimepickerModule, BsLocaleService} from 'ngx-bootstrap';

@NgModule({
    imports: [
        TimepickerModule.forRoot() 
    ],
    declarations: [

    ],
    providers: [
        BsLocaleService 
    ]
})

my.component.ts:

代码语言:javascript
复制
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

我做错了什么?

EN

回答 1

Stack Overflow用户

发布于 2018-05-14 18:01:11

我认为你应该在模块中添加这一部分

代码语言:javascript
复制
// imports

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

defineLocale('ja', jaLocale);

// @NgModule(...)
票数 0
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/50013675

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档