Pen Settings

HTML

CSS

CSS Base

Vendor Prefixing

Add External Stylesheets/Pens

Any URLs added here will be added as <link>s in order, and before the CSS in the editor. You can use the CSS from another Pen by using its URL and the proper URL extension.

+ add another resource

JavaScript

Babel includes JSX processing.

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

Packages

Add Packages

Search for and use JavaScript packages from npm here. By selecting a package, an import statement will be added to the top of the JavaScript editor for this package.

Behavior

Auto Save

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.

Format on Save

If enabled, your code will be formatted when you actively save your Pen. Note: your code becomes un-folded during formatting.

Editor Settings

Code Indentation

Want to change your Syntax Highlighting theme, Fonts and more?

Visit your global Editor Settings.

HTML

              
                <html ng-app="ionicApp">

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

  <title>Side Menus</title>

  <link href="https://code.ionicframework.com/1.0.1/css/ionic.min.css" rel="stylesheet">
  <script src="https://code.ionicframework.com/1.0.1/js/ionic.bundle.min.js"></script>
</head>

<body>

  <div ng-controller="MainCtrl">
    <ion-nav-view></ion-nav-view>
  </div>
  <script id="home1.html" type="text/ng-template">
    <ion-view view-title="Home 1">
      <ion-content has-header="true" padding="true">
        Home 1
      </ion-content>
    </ion-view>
  </script>

  <script id="home2.html" type="text/ng-template">
    <ion-view view-title="Home 2">
      <ion-content has-header="true" padding="true">
        Home 2
      </ion-content>
    </ion-view>
  </script>

  <script id="event-menu.html" type="text/ng-template">
    <ion-side-menus>
      <ion-side-menu-content>
        <ion-nav-bar class="bar-positive">
          <ion-nav-back-button></ion-nav-back-button>
          <ion-nav-buttons side="left">
            <button class="button button-icon button-clear ion-navicon" menu-toggle="left">
            </button>
          </ion-nav-buttons>
        </ion-nav-bar>
        <ion-nav-view name="menuContent"></ion-nav-view>
      </ion-side-menu-content>

      <ion-side-menu side="left">
        <ion-header-bar class="bar-assertive">
          <h1 class="title">Left Menu</h1>
        </ion-header-bar>
        <ion-content>
          <ion-list>
            <ion-item href="#/event/home" class="item" menu-close>home</ion-item>
            <ion-item href="#/event/home/home1" ng-click="closeMenu()" class="item">home 1</ion-item>
            <ion-item href="#/event/home/home2" ng-click="closeMenu()" class="item">home 2</ion-item>
            <ion-item href="#/event/check-in" class="item" menu-close>Check-in</ion-item>
            <ion-item href="#/event/attendees" class="item" menu-close>Attendees</ion-item>
          </ion-list>
        </ion-content>
      </ion-side-menu>

    </ion-side-menus>
  </script>

  <script id="home.html" type="text/ng-template">
    <ion-view view-title="Welcome">
      <ion-content has-header="true" padding="true">
        <p>Swipe to the right to reveal the left menu.</p>
        <p>(On desktop click and drag from left to right)</p>
        <a href="#/event/home/home1" class="item">home 1</a>
        <a href="#/event/home/home2" class="item">home 2</a>
      </ion-content>
    </ion-view>
  </script>

  <script id="check-in.html" type="text/ng-template">
    <ion-view view-title="Event Check-in">
      <ion-content has-header="true">
        <form class="list" ng-show="showForm">
          <div class="item item-divider">
            Attendee Info
          </div>
          <label class="item item-input">
            <input type="text" placeholder="First Name" ng-model="attendee.firstname">
          </label>
          <label class="item item-input">
            <input type="text" placeholder="Last Name" ng-model="attendee.lastname">
          </label>
          <div class="item item-divider">
            Shirt Size
          </div>
          <radio ng-repeat="shirtSize in shirtSizes" ng-value="shirtSize.value" ng-model="attendee.shirtSize">
            {{ shirtSize.text }}
          </radio>
          <div class="item item-divider">
            Lunch
          </div>
          <toggle ng-model="attendee.vegetarian">
            Vegetarian
          </toggle>
          <div class="padding">
            <button class="button button-block" ng-click="submit()">Checkin</button>
          </div>
        </form>

        <div ng-hide="showForm">
          <pre ng-bind="attendee | json"></pre>
          <a href="#/event/attendees">View attendees</a>
        </div>
      </ion-content>
    </ion-view>
  </script>

  <script id="attendees.html" type="text/ng-template">
    <ion-view view-title="Event Attendees">
      <ion-content has-header="true">
        <div class="list">
          <toggle ng-repeat="attendee in attendees | orderBy:'firstname' | orderBy:'lastname'" ng-model="attendee.arrived" ng-change="arrivedChange(attendee)">
            {{ attendee.firstname }} {{ attendee.lastname }}
          </toggle>
          <div class="item item-divider">
            Activity
          </div>
          <div class="item" ng-repeat="msg in activity">
            {{ msg }}
          </div>
        </div>
      </ion-content>
    </ion-view>
  </script>

</body>

</html>
              
            
!

CSS

              
                body {
  cursor: url('https://ionicframework.com/img/finger.png'), auto;
}
              
            
!

JS

              
                angular.module('ionicApp', ['ionic'])

.config(function($stateProvider, $urlRouterProvider) {

  $stateProvider
    .state('eventmenu', {
      url: "/event",
      abstract: true,
      templateUrl: "event-menu.html",
      controller: "MenuCtrl"
    })
    .state('eventmenu.home', {
      url: "/home",
      views: {
        'menuContent' :{
          templateUrl: "home.html"
        }
      }
    })
      .state('eventmenu.home.home1', {
      url: "/home1",
      views: {
        'menuContent@eventmenu' :{
          templateUrl: "home1.html"
        }
      }
    })
        .state('eventmenu.home.home2', {
      url: "/home2",
      views: {
        'menuContent@eventmenu' :{
          templateUrl: "home2.html"
        }
      }
    })
    .state('eventmenu.checkin', {
      url: "/check-in",
      views: {
        'menuContent' :{
          templateUrl: "check-in.html",
          controller: "CheckinCtrl"
        }
      }
    })
    .state('eventmenu.attendees', {
      url: "/attendees",
      views: {
        'menuContent' :{
          templateUrl: "attendees.html",
          controller: "AttendeesCtrl"
        }
      }
    })
  
  $urlRouterProvider.otherwise("/event/home");
})

.controller('MenuCtrl', function($scope, $ionicSideMenuDelegate, $ionicHistory) {
  $scope.closeMenu = function() {
    $ionicSideMenuDelegate.toggleLeft();
    $ionicHistory.nextViewOptions({
      disableAnimate: true
    });
  }
})

.controller('MainCtrl', function($scope) {
  console.log('MainCtrl');
  
  $scope.attendees = [
    { firstname: 'Nicolas', lastname: 'Cage' },
    { firstname: 'Jean-Claude', lastname: 'Van Damme' },
    { firstname: 'Keanu', lastname: 'Reeves' },
    { firstname: 'Steven', lastname: 'Seagal' },
    { firstname: 'Jeff', lastname: 'Goldblum' },
    { firstname: 'Brendan', lastname: 'Fraser' }
  ];
})

.controller('CheckinCtrl', function($scope) {
  $scope.showForm = true;
  
  $scope.shirtSizes = [
    { text: 'Large', value: 'L' },
    { text: 'Medium', value: 'M' },
    { text: 'Small', value: 'S' }
  ];
  
  $scope.attendee = {};
  $scope.submit = function() {
    if(!$scope.attendee.firstname) {
      alert('Info required');
      return;
    }
    $scope.showForm = false;
    $scope.attendees.push($scope.attendee);
  };
  
})

.controller('AttendeesCtrl', function($scope) {
  
  $scope.activity = [];
  $scope.arrivedChange = function(attendee) {
    var msg = attendee.firstname + ' ' + attendee.lastname;
    msg += (!attendee.arrived ? ' has arrived, ' : ' just left, '); 
    msg += new Date().getMilliseconds();
    $scope.activity.push(msg);
    if($scope.activity.length > 3) {
      $scope.activity.splice(0, 1);
    }
  };
  
});
              
            
!
999px

Console