Hide back button navigation


#1

Hi all,

Working on a ng2 app where I need to hide back button navigation. basically, after login I don’t want user to go back.

I tried this from two perspectives: First, avoiding navigation back by adding { clearHistory: true } to routerextensions call this.routerExtensions.navigate(["/"], { clearHistory: true }); and second, hiding the UI button. I tried this with:

let controller = frameModule.topmost().ios.controller;
let navigationItem = controller.visibleViewController.navigationItem;
navigationItem.setHidesBackButtonAnimated(true, false);

None of above seems to work, I still can see back button and navigate back to previous screen.
Has anyones else gone through this from an ng2, lazy load moduled app?

Thanks so much!


Disable device's navigation buttons throughout the app [Ios/Android]
#2

I’m doing that in my app using this.nav.navigate(["/main"], { clearHistory: true }); where main is is the path to my logged in component, and no Back button appears.

What does your router look like?


#3

Also, depending on how you have this setup, you might want to try using a router-outlet instead of a page-router-outlet.


#4

Hi Jon,

Thanks for your answers. Unfortunately { clearHistory: true } seems to do nothing on my app. Totally omitted, I’ve created a demo app of the issue. You can find it here:

Also, using router-outlet is not an option at all since I need the navbar there because got another action button (right side) which I need.

I’ve seen there is an PR which might get the fix for this but not sure if that PR will fix this issue especifically.

https://github.com/NativeScript/nativescript-angular/pull/637

Thanks!


#5

Just would like to mention here that 2.5.0 version fixed this issue. Passing { clearHistory: true } on navigate makes the job ok now.

Cheers!


#6

you could also do page.actionBar.navigationButton.visibility = 'collapse'


#7
import {Page} from "ui/page";

export class AppComponent {
    constructor(page: Page) {
        page.actionBarHidden = true;
    }
}

#8

This will hide entire actionBar, not only navigationButon


#9

Hello,
try this one:

<NavigationButton visibility="collapsed" ...

Dem


#10

Hi guys, any update on this???