Global variables on ionic 2

Yes, @ultradryan, that’s exactly what I was suggesting. I also used this (injectable provider class) solution and had the same problem - that some variables were not being detected as changed.

That turned out to be related to zone.js and angular2 change detection.

One (probably terrible) hack that solved things and always worked for me was to set the variable inside a setTimeout() (or similar) call because that triggers the angular2 change detection. So I did:

In the provider, injectable class that provides a variable’s value to another:

instead of this:

this.memberVariable = value;

i had this:

setTimeout(this.memberVariable = value);

and the change-detection issue went away.

I think this is a hack and at some point I’ll look more into improving on it because I dislike hacks, but it works.