I’m building an IOnic 2 app (RC4) with several Tab pages. I need to define two simple functions for a button on the navbar: one for opening a modal (login page) and one for navigating to the user profile page. If the user is not logged in yet, the login button should be displayed, and when the user is already logged in, the profile button should be displayed.
I have declared these two functions in home.ts (which is the first tab page). And this works fine on the homepage. But now I want to have these same two buttons on the other tab pages as well.
I could duplicate these functions, but I don’t want duplicate code. And it’s not just the duplicate code: I would have to import a lot of things in every single tab page: NavController, ModalController, UserPage, ProfilePage, etc.
So I should create a shared provider, right? But I read on this forum that it’s ‘bad practice’ to put navigation in providers.
So my question is simple: where should I declare global functions for opening a modal, and navigating to a specific page.
Any help would be appreciated.