$rootScope.$on("timeover", function() {
console.log("timeover event received -> redirection to Test")
$state.go('Test');
})
Now, the only missing thing is the global event listener.
However, I’m not sure how I’m supposed to add it in an ionic app.
Where do I have to put it sothat it is triggered in any page of my app?
And Why should I use windows.onclick instead of Ionic onGesture event?
The place to stick your code is in an app.run block.
Run Blocks
Run blocks are the closest thing in Angular to the main method. A run block is the code which needs to run to kickstart the application. It is executed after all of the services have been configured and the injector has been created. Run blocks typically contain code which is hard to unit-test, and for this reason should be declared in isolated modules, so that they can be ignored in the unit-tests.
You can inject services etc… into an app.run block. It’s run after angular has boostrapped itself and before any controllers have been instantiated so you’ll only need to have your code in one place.
As to which event to use? Not sure, haven’t had my morning coffee yet! I think you might have to experiment