Modify ion nav bar buttons from inside a ui-view

Hi everyone,

in our app we implemented our own split view using ui-view to load the right side pane. We implemented our own because the Ionic way of showing the side menu wasn’t enough for us. This is how it looks like:

The problem is that the buttons specified in the right pane view aren’t added to the header bar since that view isn’t the root ion-view, it’s inside a ui-view.

This is how the DOM looks like with our split view:

<ion-nav-view>
  <ion-view> <!-- Left pane ion-view -->
    <mm-split-view> <!-- Our directive -->
      <div class="mm-split-pane-menu"> <!-- Left pane items -->
      <div ui-view="mmaMessagesIndex"> <!-- Right pane container, ui-view -->
        <ion-view> <!-- Right pane ion-view -->
          <ion-nav-buttons> <!-- These buttons aren't shown -->

I looked at the ionNavButtons directive and I saw that it looks for the parent ionView, and in this case it isn’t the root ionView. So I decided to create my own directive similar to ionNavButtons, but using the outer ion-view instead of the parent one.

This had some problems too, since this relies on beforeEnter and afterEvent events, and when my right side view is loaded the events of the outer view are already fired. So I decided to trigger it myself:

parentViewCtrl.beforeEnter(undefined, {transitionId: transitionId});

With this I managed to make it work the first time I open the view. But if I go to a subview (let’s call it view B) and then come back, the header bar shown is the one from the subview (view B), not the one I want (view A). The same happens if I use the side menu to go to another view (view C) and then come back to view A, the header seen is the one from view C.

Anybody knows how to make the header bar update when going back to the view?

I know my solution is pretty hacky and I guess no one will know how to help me, but I’d appreciate any advice on how to make something like this work.

Some useful links:

Directive I created based on ionNavButtons.

Split view directive.

Thank you!

I found the problem, it was because I was using a wrong transitionId. When going back to the view a new transitionId is generated, and I needed to use that one. I use beforeEnter event to get the new transitionId.