我正在制作一个onsenui项目,我有一个导航器,它有一个后退按钮,但我正在使用角度的UI路由器来处理我的导航。
所以我有以下几种状态:
$stateProvider
.state("app", {
abstract: true,
templateUrl: "app/shared/Layout/Main.html",
controller: "NavController"
})
.state("app.buildings", {
url: "/buildings",
onEnter: function ($rootScope, $stateParams, $timeout) {
$timeout(function () {
if (!$rootScope.mobile) {
$rootScope.navLand.resetToPage("app/components/BuildingList/BuildingListView.html");
} else {
$rootScope.navPort.resetToPage("app/components/BuildingList/BuildingListView.html");
}
});
}
// templateUrl: "app/components/BuildingList/BuildingListView.html"
})
.state("app.buildings.details", {
url: "/:buildingId",
onEnter: function ($rootScope, $stateParams, $timeout) {
$timeout(function () {
if (!$rootScope.mobile) {
$rootScope.navLand.pushPage("app/components/BuildingDetail/BuildingDetailView.html");
} else {
$rootScope.navPort.pushPage("app/components/BuildingDetail/BuildingDetailView.html");
}
});
},
onExit: function ($rootScope, $state) {
$state.go("app.buildings");
if ($rootScope.navLand) $rootScope.navLand.popPage();
if ($rootScope.navPort) $rootScope.navPort.popPage();
}
})
.state("app.buildingsDetails.Category", {
url: "/buildings/:buildingId/category/:categoryId",
// templateUrl: "app/components/BuildingDetail/BuildingDetailView.html"
});
});
在我看来我尝试过:
<ons-toolbar>
<div class="left">
<ons-toolbar-button ng-click="menu.toggle()" ng-if="mobile">
<ons-icon icon="ion-navicon" size="28px" fixed-width="false"></ons-icon>
</ons-toolbar-button>
<ons-toolbar-button class="toolbar-button--quiet" ui-sref="^">
<ons-icon icon="ion-chevron-left" size="28px" fixed-width="false"></ons-icon>
Back
</ons-toolbar-button>
</div>
<div class="center"> {{vm.title}}</div>
</ons-toolbar>
你可以
背部
{{vm.title}}
所以我正在尝试使用ui-sref="^"
,但这会给我以下错误:
Error: Cannot transition to abstract state '^'
at Object.transitionTo (scripts.js:3819)
at Object.go (scripts.js:3744)
at scripts.js:4857
at angular.js:17855
at completeOutstandingRequest (angular.js:5507)
at angular.js:5784
关于我可能做错了什么的任何线索?
更新:如果我$state.go('^')
它可以正常运行