Use Angular's $window rather than window

This allow for better testability. By using this variable we can overide, remove, or mock this variable when testing.