Pen Settings

HTML

CSS

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. You can use the CSS from another Pen by using it's URL and the proper URL extention.

+ 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

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.

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>Ionic Modals</title>

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

<body>

  <ion-nav-bar class="bar-positive">
    <ion-nav-back-button class="button-icon ion-arrow-left-c">
    </ion-nav-back-button>
  </ion-nav-bar>

  <ion-nav-view></ion-nav-view>

  <script id="templates/tabs.html" type="text/ng-template">
    <ion-tabs class="tabs-icon-top tabs-positive">

      <ion-tab title="Modals" icon="ion-ios-home" href="#/tab/home">
        <ion-nav-view name="home-tab"></ion-nav-view>
      </ion-tab>

      <ion-tab title="About" icon="ion-ios-information-outline" href="#/tab/about">
        <ion-nav-view name="about-tab"></ion-nav-view>
      </ion-tab>

    </ion-tabs>
  </script>

  <script id="templates/home.html" type="text/ng-template">
    <!-- cache-view="false" will destroy the $scope on state change, triggering the $destroy event -->
    <ion-view view-title="Ionic Modals" cache-view="false">
      <ion-content class="has-header padding">
        <div class="card">
          <div class="item item-divider">
            Multiple modals with close button
          </div>
          <div class="item item-text-wrap">
            <div class="button-bar">
              <a class="button" ng-click="openModal(1)">Modal 1</a>
              <a class="button" ng-click="openModal(2)">Modal 2</a>
            </div>
          </div>
        </div>
      </ion-content>
    </ion-view>
  </script>

  <script id="templates/about.html" type="text/ng-template">
    <ion-view view-title="About">
      <ion-content class="has-header padding">
        <div class="card">
          <div class="item item-divider">
            Another page
          </div>
          <div class="item item-text-wrap">
            Text...
          </div>
        </div>
      </ion-content>
    </ion-view>
  </script>

  <!-- Modals -->
  <script id="templates/modal-1.html" type="text/ng-template">
    <div class="modal transparent">
      <div class="card">
        <i class="icon ion-ios-close close-modal" ng-click="closeModal(1)"></i>
        <div class="item item-divider">
          Header 1
        </div>
        <div class="item item-text-wrap">
          Hello from Modal 1
        </div>
      </div>
    </div>
  </script>

  <script id="templates/modal-2.html" type="text/ng-template">
    <div class="modal transparent">
      <div class="card">
        <i class="icon ion-ios-close close-modal" ng-click="closeModal(2)"></i>
        <div class="item item-divider">
          Header 2
        </div>
        <div class="item item-text-wrap">
          Hello from Modal 2
        </div>
      </div>
    </div>
  </script>

</body>

</html>
              
            
!

CSS

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

.transparent {
  background-color: transparent !important;
}

.close-modal {
  position: absolute;
  right: 0px;
  top: 5px;
  font-size: 1.8em;
  text-align: center;
  z-index: 10;
  background-color: #f5f5f5;
  border-radius: 30px;
  width: 26px;
  cursor: pointer;
  line-height: 0px;
  border: 1px solid #ddd;
}
/* Fix modal backdrop for smaller devices */

@media (max-width: 679px) {
  .active .modal-backdrop-bg {
    opacity: .5;
  }
  .modal-backdrop-bg {
    -webkit-transition: opacity 300ms ease-in-out;
    transition: opacity 300ms ease-in-out;
    background-color: #000;
    opacity: 0;
  }
}
              
            
!

JS

              
                angular.module('ionicApp', ['ionic'])
  .config(function($stateProvider, $urlRouterProvider) {
    $stateProvider
      .state('tabs', {
        url: "/tab",
        abstract: true,
        templateUrl: "templates/tabs.html"
      })
      .state('tabs.home', {
        url: "/home",
        views: {
          'home-tab': {
            templateUrl: "templates/home.html",
            controller: 'FullscreenImageCtrl'
          }
        }
      })
      .state('tabs.about', {
        url: "/about",
        views: {
          'about-tab': {
            templateUrl: "templates/about.html",
            controller: 'AboutCtrl'
          }
        }
      });
    $urlRouterProvider.otherwise("/tab/home");
  })

.controller('FullscreenImageCtrl', ['$scope', '$ionicModal',
  function($scope, $ionicModal) {
    // Modal 1
    $ionicModal.fromTemplateUrl('templates/modal-1.html', {
      id: '1', // We need to use and ID to identify the modal that is firing the event!
      scope: $scope,
      backdropClickToClose: false,
      animation: 'slide-in-up'
    }).then(function(modal) {
      $scope.oModal1 = modal;
    });

    // Modal 2
    $ionicModal.fromTemplateUrl('templates/modal-2.html', {
      id: '2', // We need to use and ID to identify the modal that is firing the event!
      scope: $scope,
      backdropClickToClose: false,
      animation: 'slide-in-up'
    }).then(function(modal) {
      $scope.oModal2 = modal;
    });

    $scope.openModal = function(index) {
      if (index == 1) $scope.oModal1.show();
      else $scope.oModal2.show();
    };

    $scope.closeModal = function(index) {
      if (index == 1) $scope.oModal1.hide();
      else $scope.oModal2.hide();
    };

    /* Listen for broadcasted messages */

    $scope.$on('modal.shown', function(event, modal) {
      console.log('Modal ' + modal.id + ' is shown!');
    });

    $scope.$on('modal.hidden', function(event, modal) {
      console.log('Modal ' + modal.id + ' is hidden!');
    });

    // Cleanup the modals when we're done with them (i.e: state change)
    // Angular will broadcast a $destroy event just before tearing down a scope 
    // and removing the scope from its parent.
    $scope.$on('$destroy', function() {
      console.log('Destroying modals...');
      $scope.oModal1.remove();
      $scope.oModal2.remove();
    });
  }
])

.controller('AboutCtrl', ['$scope',
  function($scope, $ionicModal) {
    console.log('Another $scope');
  }
]);
              
            
!
999px

Console