This version of the documentation is outdated. Check the latest version here!

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

2. Using the 'mobiscroll-instance' directive

Javascript
angular
    .module('demoApp', ['mobiscroll-datetime'])
    .controller('demoController', ['$scope', function ($scope) {
        $scope.showInstance = function () {
            $scope.myInstance.show();
        }
    }]);
HTML
<div ng-app="demoApp" ng-controller="demoController">
    <input ng-model="mydate" mobiscroll-date="settings" mobiscroll-instance="myInstance">
    <button ng-click="showInstance()">Show</button>
</div>

Setting options dynamically

To change one or more options on the component after initialization, use the setOptions method. This will update the component without losing it's internal state.

var inst = mobiscroll.scroller({
  theme: 'ios'
});
// Changes the theme to Material
inst.setOptions({ theme: 'material' });