Skip to content

Doing a 'backToPreviousPage' or Back Button to a Page using 'router-outlet' #941

Closed

Description

@jogboms

Doing a back button navigation or Using the backToPreviousPage method to a page using <router-outlet></router-outlet> results in a blank page as though the <router-outlet></router-outlet> is no longer present on the page because further routing on that page no longer works.

nativescript │ 3.2.0-2017-07-31-9530
tns-core-modules │ 3.1.1
tns-android │ 3.1.0
tns-ios │ 3.1.0
nativescript-angular | 4.3.0-2017-8-10-8
@angular/* | 4.2.6

Activity

  1. NickIliev commented on Aug 14, 2017

    @NickIliev

    Hey @jogboms we were not able to reproduce an issue using this sample project. In the project both back() and backToPreviousPage() methods are working as expected (code here). Please provide sample project or snippet which can preproduce your issue so we could investigate further.

  2. jogboms commented on Aug 14, 2017

    @jogboms
    Author

    I did a fork of this sample project and made some changes here.

  3. jogboms commented on Aug 14, 2017

    @jogboms
    Author

    @NickIliev I missed adding that i'm using the latest nativescript-angular with NativescriptAnimationsModule. I just checked your sample project.

  4. NickIliev commented on Aug 14, 2017

    @NickIliev

    @jogboms thank you for your clarifications - I can confirm that after some additional tests the issue is reproducible. We will investigate this case and will post the info in this issue.

    Steps to reproduce the issue:

    • use this sample
    • add back navigation for the ensted pages in the router-outlet

    in the component class for sub-route-one.component.ts and sub-route-two.component.ts

        constructor(private router: RouterExtensions) { }
    
        navigateBack() {
            this.router.back();
        }
    

    and add back button in the respective HTML files

    <GridLayout rows="auto, *">
        <Label row="0" text="Loaded inside the nested router" textWrap="true" class="m-16 text-center"></Label>
        <Button row="1" text="This is SECOND. Load FIRST" [nsRouterLink]="['/routing/nested-routers/first']" class="btn btn-primary btn-active"></Button>
        <Button text="navigateBack" (tap)="navigateBack()"></Button>
    </GridLayout>
    
    • navigate to the example and tap one of the nested pages than tap the button to navigate back.
      A blank page appears.

    @jogboms with the workflow used in our example backToPrevousPage works as expected (navigating back to the previous page loaded in the page-router-outlet) and the white screen is only loaded when in the nested router-outlet when there is no prevous page in the stack (which as a workaround can be controlled with a boolean flag). You might want to take a look at the provided sample and implement it as a temporary solution. Meanwhile we will post any additional info regarding this case in this issue.

  5. jogboms commented on Aug 15, 2017

    @jogboms
    Author

    @NickIliev I have looked at your sample project but it still doesn't implement my said scenario which i implemented here forking this repo.

    I am using back navigation to a page that contains Angular's router-outlet. The router-outlet doesn't seem to come up again on that page.

  6. added this to the milestone on Aug 21, 2017
  7. noomieware commented on Sep 13, 2017

    @noomieware

    @NickIliev I missed adding that i'm using the latest nativescript-angular with NativescriptAnimationsModule. I just checked your sample project.

    I have the same issue, however, I'm not using the AnimationsModule. So it seems to be a more generic router-outlet issue then bound to additional module references.

  8. blueberrynotblue commented on Oct 9, 2017

    @blueberrynotblue

    @jogboms found any tricks to workaround?

  9. jogboms commented on Oct 9, 2017

    @jogboms
    Author
  10. vakrilov commented on Oct 10, 2017

    @vakrilov
    Contributor

    Hey @jogboms - good news.
    I tried your example with the @next version and angular@4.4.0 and it seems to be working now.
    We had a big refactoring in the router implementation(#993) which probably healed the problem.

    The fix will be included in the nativescript-angular@4.4.0 but you can try it now with @next tag.

  11. jogboms commented on Oct 10, 2017

    @jogboms
    Author

    Thank you @vakrilov. Tested it out. Big ups.
    I'd incorporate it into the larger app and see how it plays with the other things.

  12. alexma01 commented on Feb 16, 2018

    @alexma01

    I have app with angular version 4.4.1 and nativescript-angular 4.4.0 but i have same problem

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

      Milestone

      Relationships

      None yet

      Development

      No branches or pull requests

      Issue actions