Issue of disabling the nav back button ($ionicGoBack)

Hi everyone…
I need anyone help about the issue of disabling the nav back button ($ionicGoBack).

I want my app user to go back to homepage if they are not logging in the app for the certain URLs. Let say if i want to restrict user if they entered “/notification” at the end of url to go Homepage
How can i prevent a back button ($ionicGoBack) top left.

can any one help me out ?

enable-menu-with-back-views=“false” is this what you want? hiding the nav back button?

I have some logic in the code that if user is not logged in than for some specific pages, if he open by manually entered the url “http://localhost:3000/#/main/insights” it return to the home page, which is done but issue is that instead of getting the home nav button, it is displaying back button something like “< Insights”

i think put this to your ion content or side menu… enable-menu-with-back-views=“false” let’s see if it works

Its already done “enable-menu-with-back-views=“false””.
if user logged in or out its always disable the back button. I want to disable the button on conditional basis

please be more specific is it the nav back button or android hardware back button you want to change?

nav back button ($ionicGoBack)

so what is your condition for the nav back button to all diff. pages?

// check here if user is logged in or not
if(!user) {
switch ($state.current.url) {
case “/notification”:
case “/gallery”:
case “/slides”:
case “/insights”:
case “/tags”:
case “/settings”:
case “/bugs”:
$ionicHistory.nextViewOptions({
disableBack: true
});
$state.go(“main.home”);
break;
default:
}
}

i think you can look to this post at stackoverflow… http://stackoverflow.com/questions/22429757/how-to-go-back-on-two-view-states-something-like-window-history-go-2 Maybe it can help you or give you a hint.

Have you tried these?
removeBackView()
Remove the previous view from the history completely, including the cached element and scope (if they exist).

clearHistory()
Clears out the app’s entire history, except for the current view.

Either of those depending on your requirement of whether you want it to remove just one step or the entire history should work.

source: http://ionicframework.com/docs/api/service/$ionicHistory/