-
Notifications
You must be signed in to change notification settings - Fork 13
options attribute
Keke edited this page Oct 19, 2020
·
4 revisions
Change value of option dynamically.
<input angular-mydatepicker [(ngModel)]="model" [options]="myDatePickerOptions"
#dp="angular-mydatepicker">
import {IAngularMyDpOptions} from 'angular-mydatepicker';
export class MyApp {
myDatePickerOptions: IAngularMyDpOptions = {
dateFormat: 'dd.mm.yyyy',
dateRange: true
// other options here
}
constructor() {}
// change value of the option dynamically
changeDateFormatDynamically(): void {
let copyOfOptions: IAngularMyDpOptions = this.getCopyOfOptions();
copyOfOptions.dateFormat = 'yyyy-mm-dd';
this.myDatePickerOptions = copyOfOptions;
}
// change value of the option dynamically
changeDatePickerModeDynamically(): void {
let copyOfOptions: IAngularMyDpOptions = this.getCopyOfOptions();
copyOfOptions.dateRange = false;
this.myDatePickerOptions = copyOfOptions;
}
// get copy of options
getCopyOfOptions(): IAngularMyDpOptions {
return JSON.parse(JSON.stringify(this.myDatePickerOptions));
}
}