Lifecycle events
The popover ships with different hooks for deep customization. Events are triggered through the lifecycle of the component where you can tie in custom functionality and code.
While users interact with the UI events like onInit, onOpen, onPosition ... will be triggered.
For a complete list of events go to the documentation See available lifecycle events →
Demo
html<mbsc-select
(onClose)="onClose($event)"
(onDestroy)="onDestroy($event)"
(onInit)="onInit($event)"
(onOpen)="onOpen($event)"
(onPosition)="onPosition($event)">
</mbsc-select>
tsonCancel(event: any): void { /* Logic for cancel button click */ }
onClose(event: any): void { /* Your custom event handler goes here */ }
onDestroy(event: any): void { /* Your custom event handler goes here */ }
onInit(event: any): void { /* Logic for label click */ }
onOpen(event: any): void { /* Your custom event handler goes here */ }
onPosition(event: any): void { /* Logic for component positioning */ }
Event log
Welcome to our website!
Have fun navigating through the demos.
ComponentTemplateCSS
import { CommonModule } from '@angular/common';
import { Component, ViewChild } from '@angular/core';
import { MbscModule, MbscPopup, MbscPopupOptions, setOptions } from '@mobiscroll/angular';
setOptions({
locale: ,
theme: ' ',
themeVariant: ' '
});
@Component({
selector: 'app-root',
templateUrl: './app.component.html',
standalone: true,
imports: [CommonModule, MbscModule],
})
export class AppComponent {
@ViewChild('popup', { static: false }) popup!: MbscPopup;
popupAnchor: HTMLElement | undefined;
popupOptions: MbscPopupOptions = {
display: 'anchored',
buttons: ['ok', 'cancel'],
};
openPopup(ev: any): void {
this.popupAnchor = ev.currentTarget;
this.popup.open();
}
onClose(): void {
// Your custom event handler goes here
}
onDestroy(): void {
// Your custom event handler goes here
}
onInit(): void {
// Logic running on component init
}
onOpen(): void {
// Your custom event handler goes here
}
onPosition(): void {
// Logic for component positioning
}
}
<mbsc-page>
<div class="mbsc-form-group">
<div class="mbsc-button-group-block">
<mbsc-button (click)="openPopup($event)">Open popup</mbsc-button>
</div>
</div>
<mbsc-popup
#popup
[anchor]="popupAnchor"
[options]="popupOptions"
(onClose)="onClose()"
(onDestroy)="onDestroy()"
(onInit)="onInit()"
(onOpen)="onOpen()"
(onPosition)="onPosition()"
>
<div class="mbsc-align-center mbsc-padding">
<img src="https://img.mobiscroll.com/demos/logo-noshadow.jpg" alt="logo" />
<h4>Welcome to our website!</h4>
<p>Have fun navigating through the demos.</p>
</div>
</mbsc-popup>
</mbsc-page>
/* style */