如何使用ng2-bootstrap datepicker选择多个日期?

时间:2017-02-10 05:40:30

标签: css angular typescript datepicker ng2-bootstrap

我正在使用ng2-boostrap datepicker和我的angular2应用程序。它工作正常,我可以选择本周日期,当用户选择本周选项时。

我浏览过的文件似乎没有办法启用日期。我怎么能实现同样的目标?

**Calendar.component.ts:**
import { Component, Output,EventEmitter} from '@angular/core'; 
@Component({
    moduleId:module.id,
    selector: 'calendar',
    templateUrl: './calendar.component.html'
})
export class CalendarComponent{
   @Output() onDatePicked: EventEmitter<any> = new EventEmitter<any>();  
  public fromDate:Date = new Date();    
  public toDate:Date = new Date();
  public closed : boolean;
  public status: string = "today"
  private events:Array<any>;
  private tomorrow:Date;
  dates = { startDate: this.fromDate, endDate: this.toDate , closed : this.closed};
  private afterTomorrow:Date;
  private formats:Array<string> = ['DD-MM-YYYY', 'YYYY/MM/DD', 'DD.MM.YYYY', 'shortDate'];
  private format = this.formats[0];
  private dateOptions:any = {
    formatYear: 'YY',
    startingDay: 1
  };
  private opened:boolean = false; 
  public constructor() {
    (this.tomorrow = new Date()).setDate(this.tomorrow.getDate() + 1);

  }
  public pickDate( ): void {
    this.dates = { startDate: this.fromDate, endDate: this.toDate , closed : false};
    this.onDatePicked.emit(this.dates);
 }      

}

Calendar.component.html:

  <datepicker [(ngModel)]="fromDate" (ngModelChange)="pickDate($event)" [showWeeks]="true"></datepicker>

0 个答案:

没有答案