Guus Vorsterman
Posts: 0
Joined: Thu Jun 18, 2015 10:05 am

Ionic header buttons in different pages and calling function

Hello,

This is related to topic Different header buttons

This works although a bit of work if you have multiple pages needing different buttons in the header.

How do you call a function in a page from a button in the header?

This is how I do it now:

Add a button and function in the header of the index page and add a broadcast in this function:

code
$scope.$broadcast('page1Event', {"a": 1, "b": 2});
/code

In page1 I add this to the init function:

code
$scope.headerButtons.showPage1Btn = true;
$scope.$on('page1Event', $scope.myFunc);
/code

and create function myFunc in page1:

code
$scope.myFunc = function (event, args) {
console.log('myFunc');
console.log(event);
console.log(args);
}
/code

This is all working. But when you have multiple pages and need multiple buttons in the header I think this is quite cumbersome.

Question is: will the Ionic header and footer component ever be supported which I think will be easier to work with?
Ionic header component

How are other developers doing this?

Serhii Kulibaba
Posts: 150
Joined: Tue Aug 27, 2013 1:47 pm

Ionic header buttons in different pages and calling function

Hello,

We are very sorry, but this is something outside the scope (http://devcenter.appery.io/support-po...) of our standard support. Please search online for appropriate solution.

Return to “Issues”