How to change message “Invalid Date” in ngx bootstrap datepicker without being in node modules

流过昼夜 提交于 2019-12-10 18:11:33

问题


I changed the language of my datepicker but the message that appears is still in English. I know it is inside ngx-bootstrap / chronos / locale / locale.defaults.ts where it brings the following information

export declare const defaultInvalidDate = "Invalid date";

I would also like to change this message. Is there any information I have to add to the "input [bsConfig] =" ... Anyway, where can I change this message without moving the Node Modules folder? Thank you.


回答1:


I finally managed to do it :

You can import your LocaleData object and the function defineLocale:

import {enGbLocale} from 'ngx-bootstrap/locale';
import {BsLocaleService, defineLocale} from 'ngx-bootstrap';

Then, in your constructor you can access every attributes of enGbLocale and modify it:

constructor(private localeService: BsLocaleService) {
    enGbLocale.invalidDate = 'Custom label';
    defineLocale('custom locale', enGbLocale); 
    this.localeService.use('custom locale');
}


来源:https://stackoverflow.com/questions/50415568/how-to-change-message-invalid-date-in-ngx-bootstrap-datepicker-without-being-i

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!