I’m wanting to do the same thing. I’m building an app that just basically has 4 apps inside it. So that leaves me with a row of tabs for navigating between the apps, and then contextual tabs that show up depending on which app you’re in. Using your example I’ve gotten the main navigation working and the contextual tabs to show, but the view is not being swapped when I click on the contextual tabs. The URL changes and using the onEnter and onExit functions in a state, I can see that it is indeed hitting that state, but for some reason the view isn’t swapping.
For example, while I’m on /storage/list it renders the app/storage/list.html file. When I click on the contextual tab Edit, the URL changes to /storage/edit, the state is entered, and app/storage/edit.html is loaded (seen via network tab in inspector), but the content is still what is in app/storage/list.html.
Relevant portion of index.html
<body ng-app="foodForAllClient" ng-controller="ClientMainCtrl">
<ion-nav-bar class="nav-title-slide-ios7 bar-calm"></ion-nav-bar>
<ion-nav-view animation="slide-left-right"></ion-nav-view>
</body>
Relevant portion of common/tabs.html
<ion-tabs class="tabs-top tabs-positive tabs-icon-only">
<ion-tab title="Storage" icon-on="ion-briefcase" icon-off="ion-briefcase" ui-sref="storage.list">
<ion-nav-view name="storage-list"></ion-nav-view>
</ion-tab>
...
</ion-tabs>
storage.js
angular.module('foodForAllClient.storage', ['ionic'])
.config(function($stateProvider, $urlRouterProvider) {
// Changing the views between these pages isn't working
// And a refresh on any of these pages (other than list) doesn't work either
$stateProvider
.state('storage', {
url: "/storage",
abstract: true,
templateUrl: "app/common/tabs.html"
})
.state('storage.list', {
url: "/list",
views: {
'storage-list': {
templateUrl: "app/storage/list.html"
}
}
})
.state('storage.cameraAdd', {
url: "/cameraAdd",
views: {
'storage-cameraAdd': {
templateUrl: "app/storage/cameraAdd.html"
}
}
})
.state('storage.add', {
url: "/add",
views: {
'storage-add': {
templateUrl: "app/storage/add.html"
}
}
})
.state('storage.edit', {
url: "/edit",
views: {
'storage-edit': {
templateUrl: "app/storage/edit.html"
}
}
});
$urlRouterProvider.otherwise("/storage/list");
})
.controller('StorageMainCtrl', function($scope) {
console.log('StorageMainCtrl');
});
app/storage/list.html (all of the files under storage look basically the same - I’m just trying to get it right)
<ion-view name="storage-list" title="Storage">
<ion-content class="padding">
<p>This is a test for the storage list</p>
</ion-content>
<div class="tabs tabs-icon-only tabs-energized">
<a class="tab-item tab-item-active" ui-sref="storage.list"><i class="icon ion-clipboard"></i></a>
<a class="tab-item" ui-sref="storage.cameraAdd"><i class="icon ion-android-camera"></i></a>
<a class="tab-item" ui-sref="storage.add"><i class="icon ion-android-add"></i></a>
<a class="tab-item" ui-sref="storage.edit"><i class="icon ion-edit"></i></a>
</div>
</ion-view>
Would you be able to steer me in the right direction?
P.S. I have this tabs state defined in my app.js that I would really like to be able to use across all my modules without having to define it in each of my controllers’ states like I do in storage.js above. Is that possible?
.state('tabs', {
url: "",
abstract: true,
templateUrl: "app/common/tabs.html"
})