Opening closing the popup
Use the popup to render any content or form in a modal box that can be programmatically shown or hidden. For that the open and close methods can be used.
To check whether the popup is opened or not, use the isVisible method.
Demo
html<mbsc-button
(click)="openPopup()"> Open popup
</mbsc-button>
<mbsc-popup #popup [options]="{display: 'center'}">
<!-- popup content -->
<mbsc-button
(click)="closePopup()"> Close
</mbsc-button>
</mbsc-popup>
tsopenPopup(): void {
this.popup.open();
}
closePopup(): void {
this.popup.close();
}
ComponentTemplate
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;
popupOptions: MbscPopupOptions = {
display: 'center',
};
openPopup(): void {
this.popup.open();
}
closePopup(): void {
this.popup.close();
}
}
<mbsc-page>
<div class="mbsc-form-group">
<div class="mbsc-button-group-block">
<mbsc-button (click)="openPopup()">Open popup</mbsc-button>
</div>
</div>
<mbsc-popup #popup [options]="popupOptions">
<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>
<div class="mbsc-button-group-block">
<mbsc-button (click)="closePopup()">Close</mbsc-button>
</div>
</mbsc-popup>
</mbsc-page>