<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>Tabs Example</title>
<link href="https://code.ionicframework.com/0.9.27/css/ionic.min.css" rel="stylesheet">
<script src="https://code.ionicframework.com/0.9.27/js/ionic.bundle.min.js"></script>
</head>
<body>
<ion-nav-bar animation="nav-title-slide-ios7"
type="bar-positive"
back-button-type="button-icon"
back-button-icon="ion-arrow-left-c"></ion-nav-bar>
<ion-nav-view animation="slide-left-right"></ion-nav-view>
<script id="tabs.html" type="text/ng-template">
<ion-tabs tabs-style="tabs-icon-top" tabs-type="tabs-positive">
<ion-tab title="Home" icon="ion-home" href="#/tab/home">
<ion-nav-view name="home-tab"></ion-nav-view>
</ion-tab>
</ion-tabs>
</script>
<script id="home.html" type="text/ng-template">
<ion-view title="'Home'">
<ion-content has-header="true" padding="true">
I'm currently in the "tabs.home" state, THE PARENT STATE<br/>
<a ui-sref="tabs.home.childLvl1">go to the "tabs.home.childLvl1" state</a>
<br/> I expect to get a right to left animation
<div class="padding">
<div class="button" ng-click="showHistory()">Show History</div>
<div class="button" ng-click="clearHistory()">Clear History</div>
<div>{{data.history}}</div>
</div>
</ion-content>
</ion-view>
</script>
<script id="childLvl1.html" type="text/ng-template">
<ion-view title="'tabs.home.childLvl1'">
<ion-content has-header="true" padding="true">
Everything is fine.<br/>
I am now in the "tabs.home.childLvl1" state<br/>
<a ui-sref="tabs.home.childLvl1.childLvl2">Lets' go to the "tabs.home.childLvl1.childLvl2" state</a>
<br/> I still expect to get a right to left animation
</ion-content>
</ion-view>
</script>
<script id="childLvl2.html" type="text/ng-template">
<ion-view title="'tabs.home.childLvl1.childLvl2'">
<ion-content has-header="true" padding="true">
I am now in the "tabs.home.childLvl1.childLvl2" state<br/>
<a style="text-decoration: underline" ng-click="goBack()">Let's go to the parent "tabs.home" state</a><br/>
As I am leaving to a parent state, I do expect to get a slide left to right animation. But I will have a right to left :'(
</ion-content>
</ion-view>
</script>
</body>
</html>
angular.module('ionicApp', ['ionic'])
.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
.state('tabs', {
url: "/tab",
abstract: true,
templateUrl: "tabs.html"
})
.state('tabs.home', {
url: "/home",
views: {
'home-tab': {
templateUrl: "home.html",
controller: 'HomeTabCtrl'
}
}
})
.state('tabs.home.childLvl1', {
url: "/childLvl1",
views: {
'[email protected]': {
templateUrl: "childLvl1.html",
controller: 'HomeTabCtrl'
}
}
})
.state('tabs.home.childLvl1.childLvl2', {
url: "/childLvl2",
views: {
'[email protected]': {
templateUrl: "childLvl2.html",
controller: 'HomeTabCtrl'
}
}
})
.state('tabs.navstack', {
url: "/navstack",
views: {
'about-tab': {
templateUrl: "nav-stack.html"
}
}
})
;
$urlRouterProvider.otherwise("/tab/home");
})
.controller('HomeTabCtrl', function($scope, $rootScope, $ionicViewService ) {
$scope.data = { "history" : ""};
$scope.showHistory = function() {
$scope.data.history = $rootScope.$viewHistory;
};
$scope.clearHistory = function() {
$ionicViewService.clearHistory();
$scope.showHistory();
};
console.log('HomeTabCtrl');
$scope.goBack = function() {
console.log('Going back');
// This will show you the history stuff.
var history = $ionicViewService.getBackView();
console.log(history);
$ionicViewService.goToHistoryRoot("002");
}
});
This Pen doesn't use any external CSS resources.
This Pen doesn't use any external JavaScript resources.