Mobiscroll Instance

When a mobiscroll component is initialized, an instance of the component is created. Through the instance you have access to all methods and properties of the component.

There are multiple ways to access the instance of an individual component.

1. Inside events

The mobiscroll instance is passed as parameter for every event of the component.

Sample usage
@Component({
    selector: 'my-example',
    template: `<input [(ngModel)]="birthday" mbsc-calendar [mbsc-options]="settings" />`
})
export class MyExampleComponent {
    birthday: Date = new Date();
    settings: MbscCalendarOptions = {
        onSet: (event, inst) => {
            const selectedDate = inst.getVal(); // Call the getVal method
        }
    };
}
@Component({
    selector: 'my-inline-example',
    template: `<mbsc-calendar [(ngModel)]="birthday" (onSet)="mySend($event)" />`
})
export class MyExampleComponent {
    birthday: Date = new Date();
    mySend(event: any) {
        const selectedDate = event.inst.getVal(); // Call the getVal method
    }
}

2. Using the instance property of the exported class

The mobiscroll directives and components are exported as 'mobiscroll' for template variables. Every exported object has an 'instance' property.

HTML Template
<mbsc-popup #myPopup="mobiscroll">
    <p>Here is the popup content</p>
</mbsc-popup>
<mbsc-button (click)="myPopup.instance.show()">Show My Popup</mbsc-button>

3. Through active instance

Stores the currently active mobiscroll instance (expcept inline instances), or null if there is no active instance.

mobiscroll.activeInstance