Pen Settings

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URL's added here will be added as <link>s in order, and before the CSS in the editor. If you link to another Pen, it will include the CSS from that Pen. If the preprocessor matches, it will attempt to combine them before processing.

+ add another resource

You're using npm packages, so we've auto-selected Babel for you here, which we require to process imports and make it all work. If you need to use a different JavaScript preprocessor, remove the packages in the npm tab.

Add External Scripts/Pens

Any URL's added here will be added as <script>s in order, and run before the JavaScript in the editor. You can use the URL of any other Pen and it will include the JavaScript from that Pen.

+ add another resource

Use npm Packages

We can make npm packages available for you to use in your JavaScript. We use webpack to prepare them and make them available to import. We'll also process your JavaScript with Babel.

⚠️ This feature can only be used by logged in users.

Code Indentation

     

Save Automatically?

If active, Pens will autosave every 30 seconds after being saved once.

Auto-Updating Preview

If enabled, the preview panel updates automatically as you code. If disabled, use the "Run" button to update.

HTML Settings

Here you can Sed posuere consectetur est at lobortis. Donec ullamcorper nulla non metus auctor fringilla. Maecenas sed diam eget risus varius blandit sit amet non magna. Donec id elit non mi porta gravida at eget metus. Praesent commodo cursus magna, vel scelerisque nisl consectetur et.

            
              <html>
  <head>
    <meta charset="utf-8">
    <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width">
    
    <title></title>

    <link href="https://code.ionicframework.com/1.1.0/css/ionic.min.css" rel="stylesheet">
     <style>
    .option-selected{
        background-color: #ccc !important;
      }
    </style>
   
    <!-- ionic/angularjs js -->
    <script src="https://code.ionicframework.com/1.1.0/js/ionic.bundle.min.js"></script>
    <script src="https://rawgit.com/inmagik/ionic-modal-select/master/dist/ionic-modal-select.js"></script>


  </head>
<body ng-app="starter" ng-controller="MainCtrl">

    <ion-pane>
      <ion-header-bar class="bar-stable">
        <h1 class="title">Ionic modal select example</h1>
      </ion-header-bar>
      <ion-content>
        <div class="item item-divider"></div>
        <div class="item item-text-wrap">
          List of numbers.
        </div>
        <div class="item item-body">
          <button class="button button-positive" modal-select="" ng-model="someModel" options="selectables" modal-title="Select a number">
            Select it
            <div class="option">
              {{option}}
            </div>
          </button>

          <button class="button button-positive" modal-select="" ng-model="someModel" options="selectables" modal-title="Select a number" has-search="true">
            Select it (with search)
            <div class="option">
              {{option}}
            </div>
          </button>


        </div>
        <div class="item">
          someModel: {{someModel}} 
        </div>

        <div class="item item-divider"></div>
        <div class="item item-text-wrap">
          Long list of numbers rendered with collection-repeat and custom header and footer set.
        </div>
        <div class="item item-body">
          <button class="button button-energized" modal-select="" ng-model="someOtherModel" options="longList" modal-title="Select a number" header-footer-class="bar-positive">
            Select it
            <div class="option">
              {{option}}
            </div>
          </button>

          <button class="button button-energized" modal-select="" ng-model="someOtherModel" options="longList" modal-title="Select a number" header-footer-class="bar-positive" has-search="true" sub-header-class="bar-positive">
            Select it (with search)
            <div class="option">
              {{option}}
            </div>
          </button>
        </div>
        <div class="item">
          someOtherModel: {{someOtherModel}}
        </div>


        <div class="item item-divider"></div>
        <div class="item item-text-wrap">
          List of objects with model bound to the option object
        </div>
        <div class="item item-body">
          <button class="button button-royal" modal-select="" ng-model="someObjModel" options="selectableNames">
            Select it
            <div class="option">
              <h2>{{option.name}}</h2>
              <p>{{option.role}}</p>
            </div>
          </button>
          <button class="button button-royal" modal-select="" ng-model="someObjModel" options="selectableNames" has-search="true">
            Select it (with search)
            <div class="option">
              <h2>{{option.name}}</h2>
              <p>{{option.role}}</p>
            </div>
          </button>
        </div>
        <div class="item">
          someUnSetModel: {{someObjModel}}
        </div>

        <div class="item item-divider"></div>
        <div class="item item-text-wrap">
          List of objects and model bound via `option-property` attribute. The initial value for this model is already set in the controller.
        </div>
        <div class="item item-body">
          <button class="button button-assertive" modal-select="" ng-model="someSetModel" options="selectableNames" option-property="name">
            {{ someSetModel || &apos;Select it&apos;}}
            <div class="option">
              <h2>{{option.name}}</h2>
              <p>{{option.role}}</p>
            </div>
          </button>
          <button class="button button-assertive" modal-select="" ng-model="someSetModel" options="selectableNames" option-property="name" has-search="true">
            {{ someSetModel || &apos;Select it&apos;}} (searchable!)
            <div class="option">
              <h2>{{option.name}}</h2>
              <p>{{option.role}}</p>
            </div>
          </button>
        </div>
        <div class="item">
          someSetModel: {{someSetModel}}
        </div>

        <div class="item item-divider"></div>
        <div class="item item-text-wrap">
          List of objects and custom getter function.
        </div>
        <div class="item item-body">
          <button class="button button-dark" modal-select="" ng-model="someThirdModel" options="selectableNames" option-getter="getOpt(option)" modal-title="Select">
            Select it
            <div class="option">
              <h2>{{option.name}}</h2>
              <p>{{option.role}}</p>
            </div>
          </button>
          <button class="button button-dark" modal-select="" ng-model="someThirdModel" options="selectableNames" option-getter="getOpt(option)" modal-title="Select" has-search="true">
            Select it - with search
            <div class="option">
              <h2>{{option.name}}</h2>
              <p>{{option.role}}</p>
            </div>
          </button>
        </div>
        <div class="item">
          someThirdModel: {{someThirdModel}}
        </div>

         <div class="item item-divider"></div>
        <div class="item item-text-wrap">
          Selection and reset callbacks
        </div>
        <div class="item item-body">
          <button class="button button-dark" modal-select="" ng-model="someFourthModel" options="selectableNames" on-select="shoutLoud(newValue, oldValue)" on-reset="shoutReset()" modal-title="Select">
            Select it
            <div class="option">
              <h2>{{option.name}}</h2>
              <p>{{option.role}}</p>
            </div>
          </button>
        </div>
        <div class="item">
          someFourthModel: {{someFourthModel}}
        </div>
        
        <div class="item item-body">
          <p>
            Repeat expression with filter
          </p>
        </div>
        <label class="item item-input">
          <span class="input-label">Filter</span>
          <input type="text" ng-model="externalFilter">
        </label>
        <div class="item item-body">
          <button class="button button-dark" modal-select="" ng-model="someSixthModel" options-expression="person in selectableNames | orderBy:'role' | filter : externalFilter" modal-title="Select">
            Select it
            <div class="option">
              <h2>{{option}}</h2>
            </div>
          </button>
          <button class="button button-dark" modal-select="" ng-model="someSixthModel" options-expression="person in selectableNames | orderBy:'role' | filter : externalFilter" modal-title="Select" has-search="true">
            Select it
            <div class="option">
              <h2>{{option}}</h2>
            </div>
          </button>
        </div>
        <div class="item">
          someSixthModel: {{someSixthModel}}
        </div>


      </ion-content>
    </ion-pane>
  </body>
</html>

            
          
!
            
              angular.module('starter', ['ionic', 'ionic-modal-select'])

.controller('MainCtrl', ['$scope', function ($scope) {
  $scope.selectables = [
    1, 2, 3
  ];

  $scope.longList  = [];
  for(var i=0;i<1000; i++){
    $scope.longList.push(i);
  }

  $scope.selectableNames =  [
    { name : "Mauro", role : "black hat"}, 
    { name : "Silvia", role : "pineye"},
    { name : "Merlino", role : "little canaglia"},
  ];

  $scope.someSetModel = 'Mauro';

  $scope.getOpt = function(option){
    return option.name + ":" + option.role;
  };
  
  $scope.shoutLoud = function(newValuea, oldValue){
    alert("changed from " + JSON.stringify(oldValue) + " to " + JSON.stringify(newValuea));
  };
  
  $scope.shoutReset = function(){
    alert("value was reset!");
  };
  
}])

.run(function($ionicPlatform) {
  $ionicPlatform.ready(function() {
    // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
    // for form inputs)
    if(window.cordova && window.cordova.plugins.Keyboard) {
      cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
    }
    if(window.StatusBar) {
      StatusBar.styleDefault();
    }
  });
})

            
          
!
999px
🕑 One or more of the npm packages you are using needs to be built. You're the first person to ever need it! We're building it right now and your preview will start updating again when it's ready.

Console