It's better to inject $window from angular because then we can mock it for tests.