我的問題是,當我瀏覽從家狀態user.tab1狀態,後退按鈕不會顯示在導航欄,我怎麼能解決這個問題,我是新來的離子型ion-nav-back-button沒有出現在我的項目結構中?
我有這個規定在我的項目:
var app = angular.module('myApp', ['ionic']);
app
.config(function ($stateProvider, $urlRouterProvider) {
$stateProvider
.state('home', {
url: '/home',
templateUrl: './templates/test/home.html'
})
.state('user', {
url: '/user',
templateUrl: './templates/test/user.html'
})
.state('user.tab1', {
url: '/tab1',
views: {
'tab1': {
templateUrl: './templates/test/tab1.html'
}
}
})
.state('user.subtab1', {
url: '/subtab1',
views: {
'tab1': {
templateUrl: './templates/test/sub-tab1.html'
}
}
})
.state('user.tab2', {
url: '/tab2',
views: {
'tab2': {
templateUrl: './templates/test/tab2.html'
}
}
});
$urlRouterProvider.otherwise("/home");
});
,這些都是模板:
的index.html
<body ng-app="myApp">
<ion-nav-bar class="bar bar-calm">
<ion-nav-back-button>
</ion-nav-back-button>
</ion-nav-bar>
<ion-nav-view>
</ion-nav-view>
</body>
home.html做爲
<ion-view view-title="Home">
<ion-content>
<a ui-sref="user.tab1">user.tab1</a>
</ion-content>
</ion-view>
user.html
<ion-view view-title="User">
<ion-tabs>
<ion-tab title="tab1" href="#/user/tab1">
<ion-nav-view name="tab1"></ion-nav-view>
</ion-tab>
<ion-tab title="tab2" href="#/user/tab2">
<ion-nav-view name="tab2"></ion-nav-view>
</ion-tab>
</ion-tabs>
</ion-view>
tab1.html
<ion-view view-title="tab1">
<ion-content>
tab1
<br />
<a ui-sref="user.subtab1">user.subtab1</a>
</ion-content>
</ion-view>
tab2.html
<ion-view view-title="tab2">
<ion-content>
tab2
</ion-content>
</ion-view>
子tab1.html
<ion-view view-title="sub-tab1">
<ion-content>
sub-tab1
</ion-content>
</ion-view>
UPDATE
我改變美國對這些,但是當我再次從家鄉導航給用戶,後退按鈕不會出現:
$stateProvider
.state('main', {
url: '/main',
abstract: true,
templateUrl: './templates/test/main.html'
})
.state('home', {
url: '/home',
parent: 'main',
views: {
'home-view': {
templateUrl: './templates/test/home.html'
}
}
})
.state('user', {
url: '/user',
parent: 'main',
views: {
'user-view': {
templateUrl: './templates/test/user.html'
}
}
})
main.html中
<ion-nav-view name="home-view">
</ion-nav-view>
<ion-nav-view name="user-view">
</ion-nav-view>
在您的用戶狀態下:將'parent:'main''更改爲'parent:'home'' –
不起作用! @AndreKreienbring –