1. First to install the Cordova plugin: plugin address: Cordova plugin add https://github.com/EddyVerbruggen/Toast-PhoneGap-Plugin.git
2. Code in Run.js: (note the parameters to be added)
. 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 ();
}
});
Double-click Exit
$ionicPlatform. Registerbackbuttonaction (function (e) {
Double-click to exit when deciding which page to be in
if ($location. path () = = '/main) {
if ($rootScope. backbuttonpressedoncetoexit) {
Ionic. Platform.exitapp ();
} else {
$rootScope. Backbuttonpressedoncetoexit = true;
$cordovaToast. Showshorttop (' Press again to exit the system ');
SetTimeout (function () {
$rootScope. Backbuttonpressedoncetoexit = false;
}, 2000);
}
}
else if ($ionicHistory. Backview ()) {
$ionicHistory. GoBack ();
} else {
$rootScope. Backbuttonpressedoncetoexit = true;
$cordovaToast. Showshorttop (' Press again to exit the system ');
SetTimeout (function () {
$rootScope. Backbuttonpressedoncetoexit = false;
}, 2000);
}
E.preventdefault ();
return false;
}, 101);
})
But do not know why return to history this one is not implemented, because the development of software pages is not particularly much, so find a solution:
else if ($ionicHistory. Currentstatename () = = ' edit ') {
}
Determines whether the current state is an edit, and then returns to the first page ~
Reference article: Http://ionichina.com/topic/5514b539b6421f9166aa5f88
Ionic implementation double-click the return key to exit the software