Sorry for necromancer, but I though it was good to clear this point.
I can't see global variables in your example. I think global variables are made with $rootScope. Maybe you meant another thing. I just point it because maybe someone come here and get confused with global/local variables.