博客
关于我
强烈建议你试试无所不能的chatGPT,快点击我
angular使用ngx-bootstrap的datepicker组件并实现本地化/国际化
阅读量:4591 次
发布时间:2019-06-09

本文共 1089 字,大约阅读时间需要 3 分钟。

datepicker组件官方api: 

 

step1. 安装 ngx-bootstrap  :

             npm install  ngx-bootstrap --save

step2 .引入相关文件:

          在angular.json中的styles中引入相关的css文件,根据需要引入相应得文件

"styles": [              "node_modules/ngx-bootstrap/datepicker/bs-datepicker.scss"            ],

在module文件中引入组件ts文件

import {BsDatepickerModule} from 'ngx-bootstrap/datepicker';import {defineLocale} from 'ngx-bootstrap/chronos';import {zhCnLocale} from 'ngx-bootstrap/locale';defineLocale('zh-cn', zhCnLocale);// 日历显示中文@NgModule({  imports: [      ...    BsDatepickerModule.forRoot()  ],  declarations: [...],  providers: [...]})

 

 组件component中

import {BsLocaleService,BsDatepickerConfig} from 'ngx-bootstrap/datepicker';export class InsuranceBuyComponent implements OnInit { bsConfig: Partial
; locale = 'zh-cn'; constructor(private fb: FormBuilder, private localeService: BsLocaleService) { } ngOnInit() {
//日期配置 this.bsConfig = Object.assign({}, {dateInputFormat: 'YYYY-MM-DD', showWeekNumbers: false}); //日期使用中文 this.localeService.use(this.locale);}}

 

在html中

 

          

         

转载于:https://www.cnblogs.com/web-wangmeng/p/9267721.html

你可能感兴趣的文章
Jmeter做接口的压力测试
查看>>
sql语句优化的30种方法
查看>>
MyISAM和InnoDB的区别
查看>>
springboot2.0 management.security.enabled无效
查看>>
spring cloud启动zipkin,报错maven依赖jar包冲突 Class path contains multiple SLF4J bindings
查看>>
源发行版8需要目标发行版1.8
查看>>
Cleartext HTTP traffic to xxx not permitted解决办法
查看>>
[Docker] Win10中安装Docker并运行Nginx镜像
查看>>
salesforce入门
查看>>
MySQL 8.017连接Navicat中出现的问题
查看>>
Css布局
查看>>
遇到的小问题
查看>>
sql server的Case When Then关键字的使用
查看>>
Css进阶
查看>>
SQL在工作中遇到的问题
查看>>
在电脑CMD中通过pip安装完部分文件后PyCharm仍无法使用的解决方法
查看>>
笨方法学Python3(21-44)
查看>>
笨方法学python3
查看>>
Linux for Matlab中文注释乱码(亲测有效)
查看>>
RK3399Pro Android Rock-X 人工智能开发系列(1)
查看>>