Ionic: How to return to the previous view after multiple navigation

Source: Internet
Author: User

When I navigate to the view, and then use the $location.path ("/path/origin") method to relocate to the initial page, after deep into the other view after the use of this method encountered a problem.

Assuming that this setting page is Viewa, if only from viewa-"VIEWB, then use the $location.path (' Viewa ') method to relocate back to Viewa without asking any questions. But if from viewa-"viewb-" VIEWC, viewc back to Viewa $location. Path (' Viewa '), the icon in the upper left corner of Viewa is not its original function button, which becomes the left arrow of the second figure as follows.

This is caused by the fact that the Web browser tracks only a single historical browsing record, while apps and WebApp require parallel independent histories, such as the VIEWB and viewc mentioned above, and we need both views to record the previous view as Viewa.

The first method:let VIEWC forget its own trail, add the following code to the VIEWC controller
$ionicHistory. nextviewoptions ({  true});

This is when you need to return from VIEWC to Viewa to use $location.path ("Viewa"), and the upper-left corner is no longer the left arrow. and print out $ionichistory.viewhistory () can be seen, at this time Viewa and the beginning of the Viewa Backview as null

If you do not add the above code to print the result is this:

  

Method Two: Return directly from VIEWC to Viewa

The GoBack method is described in the official Ionic documentation, as follows:

So, we can use this GoBack method directly in VIEWC, and return directly to Viewa in the browser's history stack:

$ionicHistory. GoBack (-2);

Print out the Viewa view history as above, Backview:null

summed up by the above method: if Viewa Backview has a value, then ionic will automatically set the upper left corner to the back button. In other words, man-made control backview so that we can get the results we want.

If the explanation is wrong, please leave a message.

Ionic: How to return to the previous view after multiple navigation

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.