2017-08-04 6 views
2

プライミングテーマのPカレンダーに問題があり、角度2の場合、ユーザーが日付を選択して空白の値を設定した後、カレンダーの値を消去します。 マイコード:primeng pcalendarの空白の値を設定する

コンポーネント

<div style="margin-right: -6px"> 
    <p-calendar [(ngModel)]="viewModel.fromDate" [showIcon]="true" readOnlyInputText="true" (click)="restoreValues()"></p-calendar> 
</div> 

typescriptファイル

export class RequestSearcherComponent implements OnInit { 


restoreValues(): void { 

    this.viewModel.areaIds = []; 
    this.viewModel.cedingIds = []; 
    this.viewModel.requestType = []; 
    this.viewModel.requestResponsible = []; 
    this.viewModel.requestStatus = []; 
    this.fromDate.setDate(null); 
    } 
} 

は、私がコードで表示されますsetDateような方法と多くの方法を試してみました。 しかし、作品:(

は誰も私を助けることはできないのですか?事前に

感謝。

答えて

2

解決!

が最善の方法ではなく、作品...

コンポーネント

<div>  
    <p-calendar #fromCal [(ngModel)]="value" [showIcon]="true" readOnlyInputText="true"></p-calendar> 
</div> 

タイプスクリプトファイル

@Component({ 
selector: 'app-request-searcher', 
templateUrl: './request-searcher.component.html' 
}) 

export class RequestSearcherComponent implements OnInit { 

@ViewChild('fromCal') calendarFrom: Calendar; 

/** My awesome code... */ 

restoreValues(): void { 

    this.calendarFrom.value = null; 
    this.calendarFrom.updateInputfield(); 

    } 
} 
関連する問題