Inside a modal
When working with the event calendar you will usually want to show an add/edit form in a popup rather than render it directly into the page markup. Simply configure the popup and add your form fields to it.
Interested in add/edit screens for events? Check out this example of a fully functional event form →
Demo
html<mbsc-button
(click)="openPopup($event)">Show modal
</mbsc-button>
<mbsc-popup [options]="popupSettings" #popup>
<div class="mbsc-form-group">
<mbsc-input label="Title"></mbsc-input>
<mbsc-textarea label="Description"></mbsc-textarea>
</div>
<div class="mbsc-form-group">
<mbsc-switch label="All-day"></mbsc-switch>
<mbsc-input label="Starts"></mbsc-input>
<mbsc-input label="Ends"></mbsc-input>
<mbsc-segmented-group name="my-group">
<mbsc-segmented [checked]="true">Show as busy</mbsc-segmented>
<mbsc-segmented>Show as free</mbsc-segmented>
</mbsc-segmented-group>
</div>
</mbsc-popup>
tsinst!: MbscPopup;
popupSettings: MbscPopupOptions = {
buttons: [
'set',
'cancel'
],
display: 'anchored',
};
openPopup(event: any): void {
this.popupSettings.anchor = event.target;
this.inst.open();
}
ComponentTemplate
import { CommonModule } from '@angular/common';
import { Component, ViewChild } from '@angular/core';
import { MbscModule, MbscPopup, MbscPopupOptions, setOptions } from '@mobiscroll/angular';
setOptions({
theme: ' ',
themeVariant: ' ',
});
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
standalone: true,
imports: [CommonModule, MbscModule],
})
export class AppComponent {
@ViewChild('popup', {
static: false,
})
inst!: MbscPopup;
popupSettings: MbscPopupOptions = {
buttons: ['set', 'cancel'],
display: 'anchored',
contentPadding: false,
responsive: {
medium: {
display: 'anchored',
width: 400,
fullScreen: false,
touchUi: false,
},
},
};
openPopup(event: any): void {
this.popupSettings.anchor = event.target;
this.inst.open();
}
}
<mbsc-page>
<mbsc-button (click)="openPopup($event)">Show modal</mbsc-button>
<mbsc-popup [options]="popupSettings" #popup>
<div class="mbsc-form-group">
<mbsc-input label="Title"></mbsc-input>
<mbsc-textarea label="Description"></mbsc-textarea>
</div>
<div class="mbsc-form-group">
<mbsc-switch label="All-day"></mbsc-switch>
<mbsc-input label="Starts"></mbsc-input>
<mbsc-input label="Ends"></mbsc-input>
<mbsc-segmented-group name="my-group">
<mbsc-segmented checked>Show as busy</mbsc-segmented>
<mbsc-segmented>Show as free</mbsc-segmented>
</mbsc-segmented-group>
</div>
</mbsc-popup>
</mbsc-page>