Pen Settings



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


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


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.


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 ng-app="ionicApp">

  <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="//" rel="stylesheet">
  <script src="//"></script>


  <ion-nav-bar class="bar-light">


  <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>

  <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-item ng-repeat="item in items">{{item}}</ion-item>






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

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

    .state('home', {
      url: "/home",
      templateUrl: "templates/home.html"

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


.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");

  $scope.doRefresh = function() {

    $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

    }, 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.__scrollLeft, -scrollView.__refreshHeight,
        scrollView.__zoomLevel, true);

      var d = new Date();

      scrollView.refreshStartTime = d.getTime();

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