2017-04-16 47 views
1

我在Web应用程序使用md2-datepicker用反应性形式,但我需要重置选择的值。 有人知道我该怎么做吗? 我试图做这样的事情,但它不适合我。最后选择的值不会重置。角4,MD2-日期选择器复位值

handleDayClick(request: any) { 
    this.request = new BookingRequest(); 
    this.request.checkIn = request.date.format(); 
    this.requestForm.setValue(this.request); 
    this.openDialog(); 
} 

也是我拥有形式的模型:

export class BookingRequest { 
    id?: number; 
    comment: string = ''; 
    checkIn: string = null; 
    checkOut: string = null; 
    approved: boolean = false; 
} 
+0

为什么不能复位? –

+0

我不知道。也许值被保存在datepicker组件例如.. –

回答

0

使用类重置价值。

export class BookingRequest { 
    id: number = null; 
    comment: string = ''; 
    checkIn: string = null; 
    checkOut: string = null; 
    approved: boolean = false; 
}