[web 前端] angular4之angular-io-datepicker
来源:互联网 发布:麻纱布料淘宝 编辑:程序博客网 时间:2024/06/18 10:49
angular-io-datepicker是一款非常漂亮的时间组件,git地址 https://www.npmjs.com/package/angular-io-datepicker
可以直接通过指令使用,指令属性如下
property type default description
mode
stringdate
Changes view mode - date, datetime, timedisabled
booleanfalse
Disables controlsshowClearButton
booleantrue
Show or not clear input buttonformat
stringdefaultFormat = {"date": "LL","datetime": "LLL","time": "LT"};
Changes view format that provides momentmode: ui展示方式,可以根据 date, datetime, time 是否展示年月日,时分秒disabled: 警用属性
format: 时间展示方式,依赖了另外一个非常好用的时间组件 moment(http://momentjs.com/)
monent提供为时间操作提供了非常简便的方法,和java的joda_time.jar一样,非常好用
Format Dates
moment().format('MMMM Do YYYY, h:mm:ss a'); // August 30th 2017, 10:15:33 ammoment().format('dddd'); // Wednesdaymoment().format("MMM Do YY"); // Aug 30th 17moment().format('YYYY [escaped] YYYY'); // 2017 escaped 2017moment().format(); // 2017-08-30T10:15:33+08:00
Calendar Time
moment().subtract(10, 'days').calendar(); // 08/20/2017moment().subtract(6, 'days').calendar(); // Last Thursday at 10:18 AMmoment().subtract(3, 'days').calendar(); // Last Sunday at 10:18 AMmoment().subtract(1, 'days').calendar(); // Yesterday at 10:18 AMmoment().calendar(); // Today at 10:18 AMmoment().add(1, 'days').calendar(); // Tomorrow at 10:18 AMmoment().add(3, 'days').calendar(); // Saturday at 10:18 AMmoment().add(10, 'days').calendar();
使用angular-io-datepicker步骤说明
第一步安装:npm i angular-io-datepicker --save
第二步:导入DatePickerModule in you AppModel
@NgModule({ declarations: [ AppComponent ], imports: [ FormsModule, ReactiveFormModule, OverlayModule, DatePickerModule, ... ], providers: [], bootstrap: [AppComponent]}) export class AppModule {}
备注: 这里的ReactiveFormModule是可选的,看你再使用组件是否使用的form 是模板驱动(Template-Driven Form) 还是模型驱动 Model-Driven Form,
html使用组件
<form #form="ngForm"> <date-picker ngModel name="date"></date-picker></form>
结果ok
遗漏问题:
在使用 ng build --prod 时会编译失败
ERROR in Error encountered resolving symbol values statically. Calling function 'ControlValueAccessorProviderFactory', function calls are not supported. Consider replacing the function or lambda with a reference to an exported function, resolving symbol DatePicker in D:/myapp/node_modules/angular-io-datepicker/src/datepicker/datePicker.d.ts, resolving symbol DatePicker in D:/myapp/node_modules/angular-io-datepicker/src/datepicker/datePicker.d.tsERROR in ./src/main.tsModule not found: Error: Can't resolve './$$_gendir/app/app.module.ngfactory' in 'D:\myapp\src' @ ./src/main.ts 4:0-74 @ multi ./src/main.tshttps://github.com/rd-dev-ukraine/angular-io-datepicker/issues/12
请大家先编译看下这个问题解决之后在使用,目前成熟的时间组件 ng2-datetime 整合 bootstrap
使用aot编译是没有问题的: ng build --prod --aot=false
阅读全文
0 0
- [web 前端] angular4之angular-io-datepicker
- 前端angular 之MVVM
- Angular4记账webApp练手项目之二(在angular4项目中使用Angular WeUI)
- 前端MVC框架之 Angular
- 【前端攻城狮之路】Angular篇
- angular4实战(1) angular-cli
- 最新angular cli 安装教程(angular4 )
- Angular-JS 与 Angular4 初接触
- angular4 安装@angular/animations等问题
- web前端之javascript
- Web前端之基础知识
- Web前端 之 RequireJS
- 初识【前端之WEB】
- Web前端之HTML
- Web前端之CSS
- web前端学习笔记-angular学习前必备知识
- angular---angular4学习笔记:angular中的模块化@NgModule装饰器
- angular4基础之路由
- 计算机学科国际会议排名
- 四种常见的 POST 提交数据方式对应的 content-type 取值
- java中split()特殊符号"." "|" "*" "\" "]"
- 学习——机器学习之初始SVM
- Java中的split函数
- [web 前端] angular4之angular-io-datepicker
- Uart通信协议
- 宝宝秀项目学习(四)
- spring mvc
- iOS 蓝牙连接的流程
- 常用网址
- 名称空间
- c++ 中子类与父类构造析构的调用和顺序
- C# 方法的定义