-
Notifications
You must be signed in to change notification settings - Fork 13
initialize date model (single date mode)
Keke edited this page Jul 12, 2019
·
1 revision
This example shows on how to initialize date model in single date selection mode.
<div class="input-box-container">
<input class="input-box" placeholder="Click to select a date"
angular-mydatepicker name="mydate" (click)="dp.toggleCalendar()"
[(ngModel)]="model" [options]="myDpOptions"
#dp="angular-mydatepicker"/>
</div>
import {IAngularMyDpOptions, IMyDateModel} from 'angular-mydatepicker';
// other imports are here...
export class MyTestApp {
myDpOptions: IAngularMyDpOptions = {
dateRange: false,
dateFormat: 'dd.mm.yyyy'
// other options are here...
};
myDateInit: boolean = true;
model: IMyDateModel = null;
constructor() { }
ngOnInit() {
if (myDateInit) {
// Initialize to specific date (14.05.2019) with IMyDate object
this.model = {isRange: false, singleDate: {date: {
year: 2019,
month: 5,
day: 14
}}};
}
else {
// Initialize to today with javascript date object
this.model = {isRange: false, singleDate: {jsDate: new Date()}};
}
}
}