Programmatic Value Control

Values can change in a couple of different ways: through defaults, interacting with the UI or programmatically. The date and time picker defaults to now, which can be easily overridden with the defaultSelection option. The values are set by interacting with the component and making a selection or it can be done programmatically by updating the bound value. Use the buttons option for showing/hiding set, cancel or add custom buttons.

Get started with this example

Demo

Controlling the default value

The calendar defaults to today if not overridden. You can however manually set a default value through the defaultSelection option.

html<mbsc-datepicker
    [controls]="['calendar']">
</mbsc-datepicker>
html<mbsc-datepicker
    [controls]="['calendar']"
    [defaultSelection]="defaultSelection">
</mbsc-datepicker>
tsdefaultSelection = new Date(2020, 11, 24);
Setting values runtime

While the selected value can be changed by interacting with the calendar, you can set the model value to change it programmatically.

htmlhtml<mbsc-button (click)="setValue()">02-01-2020</mbsc-button>
<mbsc-button (click)="setToday()">Today</mbsc-button>
<mbsc-datepicker
    [controls]="['calendar']"
    [(ngModel)]="customVal">
</mbsc-datepicker>
tssetValue() {
    this.customVal = new Date(2020, 0, 2);
}

setToday() {
    this.customVal = new Date();
}
Setting values with buttons

The button API provides shortcuts to value selection and confirmation. Add 'Now' or custom button to the component or entirely remove the 'Set' button to activate auto-set, which automatically closes the dialog if a date is selected.

htmlhtml<mbsc-datepicker
    #nowInst
    [controls]="['calendar']"
    [(ngModel)]="now"
    [isOpen]="nowOpen"
    [buttons]="nowButtons">
</mbsc-datepicker>
<mbsc-input #start placeholder="Please Select...">Outbound</mbsc-input>
<mbsc-input #end placeholder="Please Select...">Return</mbsc-input>
tsnowButtons = [{
    text: 'Now',
    handler: () => {
        this.now = new Date();
        this.nowInst.close();
    }
}, 'set', 'cancel'];
htmlhtml<mbsc-datepicker
    #customInst
    [controls]="['calendar']"
    [(ngModel)]="custom"
    [isOpen]="customOpen"
    [buttons]="customButtons">
</mbsc-datepicker>
<mbsc-input #start placeholder="Please Select...">Outbound</mbsc-input>
<mbsc-input #end placeholder="Please Select...">Return</mbsc-input>
tscustomButtons = [{
        text: '05 Jan 2020',
        handler: () => {
            this.custom = new Date(2020, 0, 5);
            this.customInst.close();
        }
    }, 'set', 'cancel'
];
htmlhtml<mbsc-datepicker
    [controls]="['calendar']"
    [buttons]="autoButtons">
</mbsc-datepicker>
<mbsc-input #start placeholder="Please Select...">Outbound</mbsc-input>
<mbsc-input #end placeholder="Please Select...">Return</mbsc-input>
tsautoButtons = [{
    text: 'Close',
    handler: 'cancel'
}];

Duplicate Session

You have signed in on a different machine. To keep everything in sync, you have been signed out of this session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.

Duplicate Session

We noticed you are logged in on a different machine and have closed your old session.

If you need to invite team members, manage seats and accounts you can do it from the licenses page.