0
是否有可能將不同的標籤鏈接到相同的視圖? 現在我有:將多個離子選項卡鏈接到同一視圖?
<ion-tabs class="tabs-icon-top tabs-color-active-positive">
<ion-tab title="Dashboard" icon-off="ion-ios-speedometer-outline" icon-on="ion-ios-speedometer" active="active.dashboard" >
<ion-nav-view name="tab-app"></ion-nav-view>
</ion-tab>
<ion-tab title="Reports" icon-off="ion-ios-pie-outline" icon-on="ion-ios-pie">
<ion-nav-view name="tab-app"></ion-nav-view>
</ion-tab>
<ion-tab title="Create" icon-off="ion-ios-plus" icon-on="ion-plus-circled" >
<ion-nav-view name="tab-app"></ion-nav-view>
</ion-tab>
<ion-tab title="Approvals" icon-off="ion-ios-bell-outline" icon-on="ion-ios-bell">
<ion-nav-view name="tab-app"></ion-nav-view>
</ion-tab>
<ion-tab title="Settings" icon-off="ion-ios-gear-outline" icon-on="ion-ios-gear" href="#/tab/settings">
<ion-nav-view name="tab-settings"></ion-nav-view>
</ion-tab>
</ion-tabs>
然而,這些選項卡中的每一個都是用製表應用的只是不同的情況下,控制器被重新加載,他們不共享任何屬性。
如何讓標籤共享相同的視圖?我想將它們鏈接在一起,並讓控制器根據所選的選項卡進行操作。謝謝!
更新,並補充路由:
.config(function($stateProvider, $urlRouterProvider) {
// Ionic uses AngularUI Router which uses the concept of states
// Learn more here: https://github.com/angular-ui/ui-router
// Set up the various states which the app can be in.
// Each state's controller can be found in controllers.js
$stateProvider
// setup an abstract state for the tabs directive
.state('tab', {
url: '/tab',
abstract: true,
templateUrl: 'templates/tabs.html',
controller: 'TabCtrl'
})
// Each tab has its own nav history stack:
.state('tab.app', {
url: '/app',
params: {state_location: null},
views: {
'tab-app': {
templateUrl: 'templates/tab-app.html',
controller: 'AppCtrl'
}
}
})
// if none of the above states are matched, use this as the fallback
$urlRouterProvider.otherwise('/tab/app');
})
我覺得你的路由將是有益的。我對離子框架並不是很熟悉,但我認爲你應該使用單個ui-view:標籤應該改變狀態。 – drakyoko
添加了路由:) – FLX