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

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>Side Menus</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-light">
    <ion-nav-back-button>
    </ion-nav-back-button>
  </ion-nav-bar>

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

  <script id="templates/home.html" type="text/ng-template">
    <ion-view view-title="Home">
      <ion-content class="padding">
        <button class="button" ui-sref="ptr">Go To PTR View</button>
      </ion-content>
    </ion-view>
  </script>

  <script id="templates/ptr.html" type="text/ng-template">
    <ion-view view-title="PTR">
      <ion-content delegate-handle="ptr-content">

        <ion-refresher on-refresh="doRefresh()">
        </ion-refresher>

        <ion-list>
          <ion-item ng-repeat="item in items">{{item}}</ion-item>
        </ion-list>
      </ion-content>
    </ion-view>
  </script>


</body>

</html>
              
            
!

CSS

              
                
              
            
!

JS

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

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

  $stateProvider
    .state('home', {
      url: "/home",
      templateUrl: "templates/home.html"
    })

  .state('ptr', {
    url: "/ptr",
    templateUrl: "templates/ptr.html",
    controller: "PtrCtrl"
  })

  $urlRouterProvider.otherwise("/home");
}])

.controller('PtrCtrl', ['$scope', '$timeout', 'PtrService', function($scope, $timeout, PtrService) {

  // Used to know whether to show ititial items or new items for a manual refresh
  var refreshed = false;

  // Start with an empty items array
  $scope.items = [];

  // When the view is loaded, trigger the PTR event.
  $scope.$on("$ionicView.loaded", function() {
    console.log("View loaded! Triggering PTR");
    PtrService.triggerPtr('ptr-content');
  })

  $scope.doRefresh = function() {

    console.log('Refreshing!');
    $timeout(function() {
      if (!refreshed) {
        $scope.items = ['Item 1', 'Item 2', 'Item 3'];
        refreshed = true;
      } else {

        //simulate async response
        $scope.items.push('New Item ' + Math.floor(Math.random() * 1000) + 4);

      }

      //Stop the ion-refresher from spinning
      $scope.$broadcast('scroll.refreshComplete');

    }, 1000);

  };

}])

.service('PtrService', ['$timeout', '$ionicScrollDelegate', function($timeout, $ionicScrollDelegate) {

  /**
   * Trigger the pull-to-refresh on a specific scroll view delegate handle.
   * @param {string} delegateHandle - The `delegate-handle` assigned to the `ion-content` in the view.
   */
  this.triggerPtr = function(delegateHandle) {

    $timeout(function() {

      var scrollView = $ionicScrollDelegate.$getByHandle(delegateHandle).getScrollView();

      if (!scrollView) return;

      scrollView.__publish(
        scrollView.__scrollLeft, -scrollView.__refreshHeight,
        scrollView.__zoomLevel, true);

      var d = new Date();

      scrollView.refreshStartTime = d.getTime();

      scrollView.__refreshActive = true;
      scrollView.__refreshHidden = false;
      if (scrollView.__refreshShow) {
        scrollView.__refreshShow();
      }
      if (scrollView.__refreshActivate) {
        scrollView.__refreshActivate();
      }
      if (scrollView.__refreshStart) {
        scrollView.__refreshStart();
      }

    });

  }
}])
              
            
!
999px

Console