So I’ve been working on a project for a couple months now (new to both ionic and AngularJS, enjoying the ride so far), and halfway through I discovered a problem I still can’t understand. The situation is the next:
A side-menu app with a simple home linking to 3 tabs (footer with formatted links, not ion-tab
's), each tab with it’s own controller, 2 of which have to execute only once.
The problem is once in the tabs, if you keep switching between two of them, the controller of one of them keeps re-running. For example, if you go to tab1, controller runs, you go to tab2, controller runs, you go back to tab1, controller doesn’t run (as expected, by going back I mean stil clicking in tabs, the routing goes back on the history stack if your next page is the last view on the stack, right?), but if then you go to tab2 the controller runs again.
I’m assuming it has a simple explanation I have been missing, like a basic logic in routing. If anyone could provide some explanation and/or solution you’d be saving me from more headaches, I hope I explained myself well enough. All I really need is the controllers not re-running. Thanks in advance.
Here is a codePen, like I said, if you go to tabs and keep switching between two of them you’ll see the console.log
's re-firing in one of them.