1, install the plug-in
Toast is compatible with Cordova Plugman, compatible with PHONEGAP 3.0 CLI, here's how it works with the CLI (backup your Project first!):
Using the Cordova CLI and the Cordova Plugin Registry
nl. xservices.plugins.toast$ Cordova Prepare
Or using the PhoneGap CLI
nl. x-services.plugins.toast
After installation, you can use the command to view http://www.cnblogs.com/cuoreqzt/p/4491943.html
2, add JS in the app
. Run (function($ionicPlatform, $rootScope, $location, $timeout, $ionicHistory) {$ionicPlatform. Ready (function () { //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 &&window.cordova.plugins.Keyboard) {Cordova.plugins.Keyboard.hideKeyboardAccessoryBar (true); } if(window. StatusBar) {//Org.apache.cordova.statusbar Requiredstatusbar.stylelightcontent (); } //Double Exit if(Window.cordova && window.plugins &&window.cordova.plugins.Toast) {$ionicPlatform. registerbackbuttonaction (function(e) {//double-exit when deciding which page to be in if($location. Path () = = '/tab/home ') { if($rootScope. backbuttonpressedoncetoexit) {ionic. Platform.exitapp (); } Else{$rootScope. backbuttonpressedoncetoexit=true; Cordova.plugins.Toast.showShortTop (' Press again to exit the system '); SetTimeout (function() {$rootScope. Backbuttonpressedoncetoexit=false; }, 2000); } } Else if($ionicHistory. Backview ()) {$ionicHistory. GoBack (); } Else{$rootScope. backbuttonpressedoncetoexit=true; Cordova.plugins.Toast.showShortTop (' Press again to exit the system '); SetTimeout (function() {$rootScope. Backbuttonpressedoncetoexit=false; }, 2000); } e.preventdefault (); return false; }, 101); } }); })
Ionic double eject key to exit the app