如何将ngx_bootstrap datepicker与frensh版本一起使用

时间:2018-01-22 14:36:16

标签: angular twitter-bootstrap ngx-bootstrap

我在我的角项目中使用ngx-bootstrap datepicker,我想使用法语版的datepicker,但它总是在英文版本中提供heres我的代码:

html:

 <input type='text' class="form-control" placeholder="Date de l'aller :" bsDatepicker formControlName="dateDepart" />

component.ts:

import { defineLocale } from 'ngx-bootstrap/chronos';
import { fr } from 'ngx-bootstrap/locale';
defineLocale('fr', fr);

有关如何使用法语版本的ngx-boostrap datepicker的任何帮助吗?

3 个答案:

答案 0 :(得分:1)

看起来您定义了区域设置,但实际上并没有设置它。从组件中的for(const user of users){ for(const file of user.files){ file.size = "newfilesize" + file.size; } } 注入BsLocaleService并调用其ngx-bootstrap/datepicker方法。点击此处的示例 - https://valor-software.com/ngx-bootstrap/#/datepicker#locales(转到use('fr')标签,然后查看代码)

答案 1 :(得分:0)

还可以在Angular的模块中为ngx-bootstrap datepicker设置语言环境。

首先,我们将语言环境导入app.module.ts中:

import { defineLocale } from "ngx-bootstrap/chronos";
import { nbLocale } from "ngx-bootstrap/locale";
defineLocale("nb", nbLocale); //only setting up Norwegian bokmaal (nb) in this sample
export class AppModule {
 constructor(private bsLocaleService: BsLocaleService) {
    this.bsLocaleService.use('nb');
    }
}

现在,我们所有的ngx-bootstrap日期选择器都将具有指定的语言环境挪威语。当然,您可以切换到其他语言环境,请记住为这些语言环境输入字符串文字,使其小写。

答案 2 :(得分:0)

对于西班牙语(Datepicker),将此代码添加到app.module中:

import { BsDatepickerModule, BsLocaleService } from 'ngx-bootstrap/datepicker';
import { defineLocale } from 'ngx-bootstrap/chronos';
import { esLocale } from 'ngx-bootstrap/locale';
defineLocale('es', esLocale);

export class AppModule { 
  constructor( private bsLocaleService: BsLocaleService){
    this.bsLocaleService.use('es');//fecha en español, datepicker
  }

}