Back button not enabled even after using router


#1

Hi,
I am following the tutorial http://docs.nativescript.org/angular/tutorial/ng-chapter-3. All worked well, until I moved to using router logic. As described in the tutorial, I should see a back button on android simulator, after integrating login functionality and adding code:

login() {
this.userService.login(this.user)
.subscribe(
() => this.router.navigate(["/list"]),
(error) => alert(“Unfortunately we could not find your account.”)
);
}

I do get the next screen of list page but, but no back navigation on top.

Can some one pls explain?


#2

Hi!

Have you checked if the page being navigated to has the “Back Button” coded into it? If you’re doing the Android version, the tutorial shows the page without that button, which probably means they don’t code it into the example.


#3

If you look in the tutorial on the android image/gif, there’s no back button on the action bar, only on IOS. If you want to add a back button on the action bar on android you would need code something like: <NavigationButton text="Go Back" android.systemIcon="ic_menu_back" (tap)="function()"></NavigationButton>.

function() can be any function that you want.

To change the Android icon, swap ic_menu_back with any one of the codes from here: http://androiddrawables.com/

For ios, change Go Back to whatever text you want.

Hope this helps