如何更改消息“无效日期"在ngx bootstrap datepicker中,而不在节点模块中 [英] How to change message "Invalid Date" in ngx bootstrap datepicker without being in node modules
问题描述
我更改了日期选择器的语言,但是出现的消息仍然是英语.我知道它在ngx-bootstrap/chronos/locale/locale.defaults.ts中,它带来以下信息
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";
我也想更改此消息.我必须在输入[bsConfig] ="..."中添加任何信息吗,无论如何,在不移动Node Modules文件夹的情况下可以在何处更改此消息?谢谢.
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.
推荐答案
我终于设法做到了:
您可以导入LocaleData
对象和函数defineLocale
:
You can import your LocaleData
object and the function defineLocale
:
import {enGbLocale} from 'ngx-bootstrap/locale';
import {BsLocaleService, defineLocale} from 'ngx-bootstrap';
然后,在构造函数中,您可以访问enGbLocale
的每个属性并对其进行修改:
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');
}
这篇关于如何更改消息“无效日期"在ngx bootstrap datepicker中,而不在节点模块中的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!