How do i best create a dynamic toolbar?

i need a dynamic toolbar that changes its buttons and the associated actions based on the rest of the page

reading through the examples and source of nav bar, tabs and the like im still not sure how the communication works

i would like to use ionic as much as possible so the question is:

whats my best way to get the information (what buttons to show etc.) out of my main view (should be ion-view) and how do i implement the logic (clicking on btn a does b in the views controller)

the thing ill try now is using a toolbarService that gets used in all my views controllers and is used by those to store the buttons to show and is used by the toolbarController to update the view

but i still have no idea how i would trigger a function in the views controllers by clicking on a button in the toolbar that uses a different controller

Hey,

i have built such a service, too (for a dynamic footer).
-> the magic word is “callback”

if you set the buttons in your controller -> pass an additional key named like callback or onTap to it.

toolbarService.set({
   buttons: [{
      text: 'MyButton',
      class: 'stylingClass',
      callback: function () {
         // Put your magic in!
      }
   }]
});

This is a function that should called after you press this button.
It also can be a function on the controllers $scope.

Ionic does it the same way for ionicPopUps :wink:

ok ill try that, does the callback function have access to the controllers scope? or how else does it call functions on there?

edit:// after building a test app it does work as expected and uses the same scope, thank you!