3
我想要自定义导航点击后退按钮。这个想法是发送用户到主页,在应用程序中他按下硬件后退按钮,当主页退出应用程序。无法使用location.path从registerBackButtonAction导航
本次活动的作品,但新视图不会加载且如果后再次按下按钮的应用程序退出
的index.html:
<body ng-app="starter" ng-controller="AppCtrl">
<ion-nav-view></ion-nav-view>
</body>
JS:
.controller('AppCtrl', function($scope, $http, $location, $ionicModal, $ionicPlatform, $rootScope) {
// Register back button
$ionicPlatform.registerBackButtonAction(function (event) {
// Custom function
event.preventDefault(); // Back button will DO NOTHING.
var path = $location.path();
if (path.indexOf('home') != -1) {
navigator.app.exitApp();
return;
}
$location.path('/app/home');
}, 100);
})
我甚至用内部相同的代码尝试过
angular.module('starter', ['ionic', 'starter.controllers'])
.run(function($location, $ionicPlatform, $rootScope) {}
有没有人如何使它工作?
你整理了吗? – 2016-09-13 10:48:57
不,我改变了功能 – vikramaditya234 2016-09-16 11:25:36