|
6#
楼主 |
发表于 2016-4-19 10:27:14
|
只看该作者
angular.module('myApp', ['ionic','myApp.controllers','ngCordova'])
.run(function ($ionicPlatform, $rootScope, $location, $timeout, $ionicHistory, $cordovaToast) {
$ionicPlatform.ready(function ($rootScope) {
// Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
// for form inputs)
if (window.cordova && window.cordova.plugins.Keyboard) {
cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
}
if (window.StatusBar) {
// org.apache.cordova.statusbar required
StatusBar.styleDefault();
}
});
//双击退出
$ionicPlatform.registerBackButtonAction(function (e) {
//判断处于哪个页面时双击退出
if ($location.path() == '/tabs/tab-sy') {
if ($rootScope.backButtonPressedOnceToExit) {
ionic.Platform.exitApp();
} else {
$rootScope.backButtonPressedOnceToExit = true;
$cordovaToast.showShortCenter('再按一次退出系统');
setTimeout(function () {
$rootScope.backButtonPressedOnceToExit = false;
}, 1000);
}
}
else if ($ionicHistory.backView()) {
$ionicHistory.goBack();
} else {
$rootScope.backButtonPressedOnceToExit = true;
$cordovaToast.showShortCenter('再按一次退出系统');
setTimeout(function () {
$rootScope.backButtonPressedOnceToExit = false;
}, 1000);
}
e.preventDefault();
return false;
}, 101);
})
|
|