Skip to content
This repository was archived by the owner on Sep 11, 2018. It is now read-only.
This repository was archived by the owner on Sep 11, 2018. It is now read-only.

Empty component on router.back #89

@Tompote

Description

@Tompote

Hi !
I'm trying to handle the android back button behaviour.
By default, pushing the button closes the app, but in my case it would be better to use the router.back().

So I simply added this code (coming from a fresh seed) inside app.component.ts:

ngOnInit() {
    if (!isAndroid) {
        return;
    }

    application.android.on(application.AndroidApplication.activityBackPressedEvent, (data: application.AndroidActivityBackPressedEventData) => {
        data.cancel = true;
        this.router.back(); // from RouterExtensions
    });
}`

When I push the back button I can see the app is navigating back (the active menu link changes) but it shows an empty component.

I tried the same code using Nativescript Playground as I thought it was a routing context problem, but it worked fine in every configurations (with one or multiple routers, with and without page-router-outlet...).
Here is a sample that works fine: PlaygroundSample.

Surely there is something I'm missing but I don't have any clues on what could cause different behaviour between the seed and the default playground project.
If someone could point me on the right direction that would be a huge help :)

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Type

    No type

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions