Ionic can also be animated when jumping pages with $state.go ()

Source: Internet
Author: User

In the Ionic project, the HTML tag to achieve an animated switch page is simple, as long as the label to add nav-direction= "back" or nav-direction= "forward" can be achieved. But with $state.go () How to achieve animation effect. It is also very simple, just add $ionicViewSwitcher after $state.go (). Nextdirection ("Back") or $ionicViewSwitcher. Nextdirection ("Forwoard") You can achieve the same effect as add nav-direction, remember to inject ionicviewswitcher service. What if you want to implement this effect on the Android phone's return key?

The first thing to do is register the return key time in the. Run method, and then add $ionicviewswitcher.nextdirection ("Back") after $ionichistory.goback () or Ionicviewswitcher.nextdirection ("Forwoard")

$ionicPlatform. Registerbackbuttonaction (function (e) {


E.preventdefault ();


function Showconfirm () {
var confirmpopup = $ionicPopup. Confirm ({
Title: ' <strong> exit Application?</strong> ',
Template: ' Are you sure you want to quit the app? ',
Oktext: ' Exit ',
Canceltext: ' Cancel '
});


Confirmpopup.then (function (res) {
if (res) {
Ionic. Platform.exitapp ();
} else {
Don ' t close
}
});
}


Is there a page to go?
if ($location. path () = = '/tab/dash ') {
Showconfirm ();
} else if ($ionicHistory. Backview ()) {


Go Back on history
$ionicHistory. GoBack ();
$ionicViewSwitcher. Nextdirection ("Back");
} else {
The last Page:show confirmation popup
Showconfirm ();
}


return false;
}, 101);

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.