Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

Mutiple views in one tab

$
0
0

Hi everyone,
Here is a simple example of what I'm trying to do.
I have 2 tabs (Home and News) and 3 views (Home, News and Details).
When I click on the Home and News tabs, it displays respectively the Home and News pages.
Here is my routing file:

.config(function($stateProvider, $urlRouterProvider) {
$stateProvider
	.state('tabs', {
		url: '/tabs',
		abstract: true,
		templateUrl: 'templates/tabs.html',
	})
		.state('tabs.home', {
			url: '/home',
			views: {
				'home-tab': {
					templateUrl: 'templates/home.html',
					controller: 'HomeCtrl'
				}
			}
		})
		.state('tabs.news', {
			url: '/news',
			views: {
				'news-tab': {
					templateUrl: 'templates/news.html',
					controller: 'NewsCtrl'
				}
			}
		})
		.state('tabs.details', {
			url: '/details',
			views: {
				'details-tab': {
					templateUrl: 'templates/details.html',
					controller: 'DetailsCtrl'
				}
			}
		})
$urlRouterProvider.otherwise('/tabs/home');			

});

And here is my tabs view:

<ion-tabs class="tabs-icon-top tabs-positive ">
	<ion-tab title="Home" icon="ion-home" ui-sref="tabs.home">
		<ion-nav-view name="home-tab"></ion-nav-view>
	</ion-tab>
	<ion-tab title="News" icon="ion-social-reddit" ui-sref="tabs.news">
		<ion-nav-view name="news-tab"></ion-nav-view>
	</ion-tab>
</ion-tabs>

I think it's OK...
Now I want to go to the Details page from the News page. So i added a button in the News page like this:

<ion-view view-title="News">
	<ion-content class="padding content-stable">
		<button class="button button-positive" ui-sref="tabs.details">Go to Details</button>
	</ion-content>
</ion-view>

When I click on the button, I'm still on the same page and my view remains the same. It's weird... However, the URL in my browser has changed to

http://localhost:8101/#/tabs/details

which proves that the state has changed. I probably missed one thing ... but what???


Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>