A Pen by aaron k saunders on CodePen.
Created
September 10, 2015 15:09
-
-
Save aaronksaunders/23e9c7e71528666bcf85 to your computer and use it in GitHub Desktop.
Demo ui-router basic state change
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <html> | |
| <head> | |
| <meta charset="utf-8"> | |
| <meta name="viewport" content="initial-scale=1, maximum-scale=1, user-scalable=no, width=device-width"> | |
| <link href="http://code.ionicframework.com/1.0.0/css/ionic.min.css" rel="stylesheet"> | |
| <script src="http://code.ionicframework.com/1.0.0/js/ionic.bundle.js"></script> | |
| </head> | |
| <body ng-app="app"> | |
| <ion-nav-bar class='bar-positive'> | |
| <ion-nav-back-button class="button-clear"> | |
| <i class="ion-arrow-left-c"></i> Back | |
| </ion-nav-back-button> | |
| </ion-nav-bar> | |
| <ion-nav-view animation="slide-left-right"></ion-nav-view> | |
| <script type="text/ng-template" id="home.html"> | |
| <ion-view title="Home"> | |
| <ion-content class="padding"> | |
| <button class="button button-assertive" ui-sref="detail"> | |
| Goto State 'detail' | |
| </button> | |
| <pre class="padding">{{stateInfo | json}}</pre> | |
| </ion-content> | |
| </ion-view> | |
| </script> | |
| <script type="text/ng-template" id="detail.html"> | |
| <ion-view title="Detail"> | |
| <ion-content class="padding"> | |
| <pre class="padding">{{stateInfo | json}}</pre> | |
| </ion-content> | |
| </ion-view> | |
| </script> | |
| </body> | |
| </html> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| myApp = angular.module('app', ['ionic']); | |
| myApp.config(function($stateProvider, $urlRouterProvider) { | |
| // | |
| // For any unmatched url, redirect to /state1 | |
| $urlRouterProvider.otherwise("/home"); | |
| // | |
| // Now set up the states | |
| $stateProvider | |
| .state('home', { | |
| url: "/home", | |
| templateUrl: "home.html", | |
| controller :"homeCtrl" | |
| }) | |
| .state('detail', { | |
| url: "/detail", | |
| templateUrl: "detail.html", | |
| controller :"detailCtrl" | |
| }); | |
| }) | |
| .controller('homeCtrl', function($scope, $state) { | |
| $scope.stateInfo = $state.current; | |
| }) | |
| .controller('detailCtrl', function($scope, $state) { | |
| $scope.stateInfo = $state.current; | |
| }) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment