ace-component
Version:
ace-components for ewms
62 lines (53 loc) • 1.54 kB
text/typescript
import { Component, OnInit, ViewEncapsulation, Input,EventEmitter, Output, ViewChild,ElementRef, OnChanges } from '@angular/core';
export class AceDatePickerComponent implements OnInit {
datePicker;
placeholder:string = "Select a min date";
mode:string = "daytime";
min:string; //最小时间
minDate=null;
maxDate=null;
max:string; //最大时间
onchange = new EventEmitter();
public value:string; //选中的值
public format='YYYY-MM-DD HH:mm:ss';
public showTime:boolean=true;
constructor(
private el:ElementRef
) {};
changed(value){
this.onchange.emit(value);
};
ngOnInit() {
this.setMode();
}
ngOnChanges(){
if(this.max){
this.maxDate = new Date(this.max.replace(/-/g,'/'));
}
if(this.min){
this.minDate = new Date(this.min.replace(/-/g,'/'));
}
};
setMode(){
if(this.mode=='day'){
this.format ='YYYY-MM-DD';
this.showTime = false;
}
};
disabledDate=(date)=>{
var result = false;
if(this.maxDate&&date.getTime()>this.maxDate.getTime()){
result = true;
}
if(this.minDate&&date.getTime()<this.minDate.getTime()){
result = true
};
return result;
}
}