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.

            
              <!DOCTYPE html>
<html ng-app="ionicApp">

  <head>
    
<meta name="description" content="Combined 'Navigation and Routing Part 2' and 'Sharing Data Between Views' from learn.ionicframework.com" />
    
    <link data-require="ionic@1.0.0-beta6" data-semver="1.0.0-beta6" rel="stylesheet" href="https://code.ionicframework.com/1.0.0-beta.6/css/ionic.css" />
    <script data-require="ionic@1.0.0-beta6" data-semver="1.0.0-beta6" src="https://code.ionicframework.com/1.0.0-beta.6/js/ionic.bundle.js"></script>
    
  </head>

  <body>
<ion-nav-view animation="slide-left-right"></ion-nav-view>

    
     <script type="text/ng-template" id="main.html">
      
      <ion-nav-bar class="bar-calm">
  <ion-nav-back-button class="button-clear">
    <i class="ion-arrow-left-c"></i> Back
  </ion-nav-back-button>
</ion-nav-bar>
      <ion-tabs class="tabs-positive">
        <ion-tab icon="ion-home" ui-sref="app.home">
          <ion-nav-view name="vHome"></ion-nav-view>
        </ion-tab>
        <ion-tab icon="ion-help" ui-sref="app.help">
          <ion-nav-view name="vHelp"></ion-nav-view>
        </ion-tab>
        <ion-tab icon="ion-clipboard" ui-sref="app.todos">
          <ion-nav-view name="vTodos"></ion-nav-view>
        </ion-tab>
      </ion-tabs>
    </script>
   
    <script type="text/ng-template" id="help.html">
      <ion-view title="Help">
        <ion-content padding="true">
           <h2>Using the app</h2>
           <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facilis architecto hic officia quasi excepturi sequi deleniti maiores consectetur veritatis sint?</p>
        </ion-content>
      </ion-view>
    </script> 
    
    <script type="text/ng-template" id="home.html">
      <ion-view title="Home">
        <ion-content padding="true">
           <h2>Welcome!</h2>
           <p>Lorem ipsum dolor sit amet, consectetur adipisicing elit. Facilis architecto hic officia quasi excepturi sequi deleniti maiores consectetur veritatis sint?</p>
        </ion-content>
      </ion-view>
    </script> 
    
    

    <script type="text/ng-template" id="todos.html">
      <ion-view title="Todos">
        <ion-content>
          <ion-list>
            <ion-item ng-repeat="todo in todos" class="item item-icon-right" ui-sref="app.todos.detail({todoId: todo.id})">
              <span ng-class="{done: todo.done}">{{todo.name}}</span>
              <i class="icon ion-ios7-arrow-right"></i>
            </ion-item>
            
          </ion-list>
        </ion-content>
      </ion-view>
    </script>
    
                <!-- <ion-item ng-repeat="todo in todos" class="item item-icon-right" ui-sref="app.todos.detail({todo: $index})">
              <span ng-class="{done: todo.done}">{{todo.title}}</span>
              <i class="icon ion-ios7-arrow-right"></i>
            </ion-item> -->
            
            <!--ion-item ng-repeat="todo in todos" ui-sref='todo({todoId: todo.id})' ng-class='{done: todo.done}'>{{todo.name}}</ion-item-->
    


    <script type="text/ng-template" id="todo.html">
      <ion-view title="Edit Todo">
        <ion-content>
          <div class="list">
            <label class="item item-input">
              <span class="input-label">Name</span>
              <input type="text" ng-model="todo.name">
            </label>
            <ion-toggle ng-model="todo.done" toggle-class="toggle-calm">Done</ion-toggle>
          </div>
        </ion-content>
      </ion-view>
    </script>
    
    
    
    
  </body>
</html>


            
          
!
            
              .done {
  text-decoration: line-through;
}

            
          
!
            
              var app = angular.module('ionicApp', ['ionic'])


//app.factory('TodosService', function() {
app.service('TodosService', function($q) {
  
  //var todos = [ {title: "Do Laundry", done: true} ];

  return {
    todos: [
      {
        id: '1',
        name: 'Pick up apples',
        done: false
      },
      {
        id: '2',
        name: 'Mow the lawn',
        done: true
      },
      {id: '3', name: "Take out the trash", done: true},
      {id: '4', name: "Do laundry", done: false},
      {id: '5', name: "Start cooking dinner", done: false}
    ],
    
    //todos: todos,
    //getTodo: function(todoId) { return todos[todoId] }

    getTodos: function() {
      return this.todos;
    },
    
    getTodo: function(todoId) {
      var dfd = $q.defer()
      this.todos.forEach(function(todo) {
        if (todo.id === todoId) dfd.resolve(todo)
      })

      return dfd.promise
    }
  }
})



app.config(function($stateProvider, $urlRouterProvider) {
  
  $stateProvider.state('app', {
    abstract: true,
    templateUrl: 'main.html'
  })
  
  $stateProvider.state('app.help', {
    url: '/help',
    views: {
      vHelp: {
        templateUrl: 'help.html'
      }
    }
  })
  
  $stateProvider.state('app.home', {
    url: '/home',
    views: {
      vHome: {
        templateUrl: 'home.html'
      }
    }
  })


  $stateProvider.state('app.todos', {
    abstract: true,
    url: '/todos',
    views: {
      vTodos: {
        template: '<ion-nav-view></ion-nav-view>'
      }
    }
  })

  $stateProvider.state('app.todos.index', {
    url: '',
    controller: 'TodosCtrl',
    templateUrl: 'todos.html',
    resolve: {
      todos: function(TodosService) {
        return TodosService.getTodos();
      }
    }
  })

  $stateProvider.state('app.todos.detail', {
    url: '/:todoId',
    controller: 'TodoCtrl',
    templateUrl: 'todo.html',
    resolve: {
      todo: function($stateParams, TodosService) {
        return TodosService.getTodo($stateParams.todoId)
      }
    }
  })

$urlRouterProvider.otherwise('/todos')
})




//
// Todo list view
//
app.controller('TodosCtrl', function($scope, todos) {
  $scope.todos = todos
})

/* app.controller('TodosCtrl', function($scope, TodosService) { $scope.todos = TodosService.todos; }) */

//
// Todo detail view
//
app.controller('TodoCtrl', function($scope, todo) {
  $scope.todo = todo;
})

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

Console