Using the ionic when developing the phone back button to monitor the problem ~

Source: Internet
Author: User

Tag: UIL cancels the location return key. SH Roots Register sed return

At that time used is ionic development an app, the demand is, when press the phone's return button, in the specified page double exit, while on the other page click once back to the previous page;

In fact, with Ionic services can be solved:

//Double Exit$ionicPlatform. Registerbackbuttonaction (function(e) {//double-exit when deciding which page to be inif($location. Path () = = '/message ' | | $location. path () = = '/work ' | | $location. path () = = '/mine ' | | $location. path () = = '/login ‘){   if($rootScope. backbuttonpressedoncetoexit) {$rootScope. Disconnect (); Ionic.   Platform.exitapp (); } Else{$rootScope. backbuttonpressedoncetoexit=true; $CommonFactory. Showtoast (' Press again to exit the program ', ' short ', ' bottom '); $timeout (function() {$rootScope. Backbuttonpressedoncetoexit=false; }, 2000); }  }Else{$CommonFactory. Topback ();  } e.preventdefault (); return false; }, 101);

However, I used the Hbuider editor, can debug one side on the phone to see, all appear to not be able to return to exit;

Monitoring the phone return key can also be implemented in Hbuider:

function (e) {                      plus.key.addEventListener(function(e) {               plus.nativeUI.confirm (        function(event) {             if  (event.index) {            plus.runtime.quit ();            }        null, ["Cancel", "OK"]);        false ); });

Because Ionic is based on the PhoneGap compiler platform, there is no effect when debugging with Hbuilder;

Using ionic to develop the phone back button when you encounter the problem ~

Related Article

Contact Us

The content source of this page is from Internet, which doesn't represent Alibaba Cloud's opinion; products and services mentioned on that page don't have any relationship with Alibaba Cloud. If the content of the page makes you feel confusing, please write us an email, we will handle the problem within 5 days after receiving your email.

If you find any instances of plagiarism from the community, please send an email to: info-contact@alibabacloud.com and provide relevant evidence. A staff member will contact you within 5 working days.

A Free Trial That Lets You Build Big!

Start building with 50+ products and up to 12 months usage for Elastic Compute Service

  • Sales Support

    1 on 1 presale consultation

  • After-Sales Support

    24/7 Technical Support 6 Free Tickets per Quarter Faster Response

  • Alibaba Cloud offers highly flexible support services tailored to meet your exact needs.