css Audio - Active file-generic CSS - Active Generic - Active HTML - Active JS - Active SVG - Active Text - Active file-generic Video - Active header Love html icon-new-collection icon-person icon-team numbered-list123 pop-out spinner split-screen star tv

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 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>
            
          
!
            
              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;
  }
}
            
          
!
            
              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
🕑 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.
Loading ..................

Console