简体   繁体   English

angular2日期滑块组件打字稿

[英]angular2 date slider component typescript

Does anyone know of any slider components that work with dates for angular2? 有人知道与angular2的日期兼容的任何滑块组件吗? Or a way I could adapt an existing slider that may not work with dates to be able to work with dates? 还是我可以改编可能无法与日期一起使用的现有滑块以使其能够与日期一起使用? Thank you! 谢谢!

尝试使用primeng https://www.primefaces.org/primeng/#/slider的组件

Make this try in Angular2 Material slider . Angular2材质滑块中进行尝试。

and set max and min for your date of start and end.Next,get change of @output then convert to your date. 并设置开始日期和结束日期的maxmin 。接下来, change @output其转换为日期。

html HTML

<md-slider thumbLabel min="0" [max]="datediff" (change)="getchange($event)" ></md-slider>

<p>{{nowchoose}}</p>
<!-- now choose is support date to parse what you want.-->

ts TS

getchange($event){
  this.nowchoose = new Date($event.value*24*60*60*1000).getTime();
  this.nowchoose= new Date(this.datestart.getTime() + this.nowchoose );  
}
constructor(){
  this.datestart = new Date("1911-1-1");
  this.datesend = new Date("2017-1-1");
  this.datediff=(this.datesend- this.datestart)/24/60/60/1000;
}

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM