Ion-nav-buttons and conditionally showing

This is most likely a silly Angular question than an issue with Ionic. I’ve got this in my core index.html:

<ion-nav-bar class="bar-positive">
	<ion-nav-buttons side="left">
		<button class="button" ng-click="goHome()" ng-show="notHome">
		Home
		</button>
	</ion-nav-buttons>
</ion-nav-bar>

<ion-nav-view>
</ion-nav-view>

The idea is I need a conditionally shown button in the header. I know Ionic has a back button directive like that, but my app has a home page that is temporary. Because of that, I need to control when the button shows up by hand. In my controllers I’m using a variable called notHome that I set to true when I’m not on the first two views I consider home (the temporary one and the real one).

In my testing though the button never shows up. As I said, this smells more like me screwing up something in Angular.

So - switching to using rootScope worked. And I think I mostly understand why. :wink:

yep - good find

I had same issue in a Sidemenu setup. Using $rootScope makes it work - and it does make sense when you think about it.

i found this

Not sure I understand why this should require $rootScope to work - if notHome is set in the view controller, shouldn’t that be enough?

Im having a similar problem, but in my case the button shows up sometimes, and sometimes not. If I force a state refresh it renders. Maybe there is something in the digest cycle that isn’t in sync with when ng-show is tested.

If I remember right, grege, the issue was that the code was outside of ion-nav-view, so it wasn’t “controller”-aware. Been a while though.

Just a note here - I got around my issue by using state object to resolve the data before the controller is instantiated. See: http://learn.ionicframework.com/formulas/data-the-right-way/ , and the section on resolve here - https://github.com/angular-ui/ui-router/wiki