$window is an Angular service which reference to the browser's window object. The window object is
globally available in JavaScript; it causes testability problems, because it is a global variable. Angular refer to it
through the $window service, so that it can be overridden, removed or mocked for testing.
<script>
var app = angular.module('windowExample', []);
app.controller('ExampleController',function ($scope, $window) {
$scope.greeting = 'Hello, World!';
$scope.doGreeting = function (greeting) {
$window.alert(greeting);
};
});
</script>
<div ng-app="windowExample" ng-controller="ExampleController">
<input type="text" ng-model="greeting" />
<button ng-click="doGreeting(greeting)">ALERT</button>
</div>