EVOLUTION-MANAGER
Edit File: $window.html
<a href='https://github.com/angular/angular.js/edit/v1.3.x/src/ng/window.js?message=docs($window)%3A%20describe%20your%20change...#L3' class='improve-docs btn btn-primary'><i class="glyphicon glyphicon-edit"> </i>Improve this Doc</a> <a href='https://github.com/angular/angular.js/tree/v1.3.9/src/ng/window.js#L3' class='view-source pull-right btn btn-primary'> <i class="glyphicon glyphicon-zoom-in"> </i>View Source </a> <header class="api-profile-header"> <h1 class="api-profile-header-heading">$window</h1> <ol class="api-profile-header-structure naked-list step-list"> <li> - service in module <a href="api/ng">ng</a> </li> </ol> </header> <div class="api-profile-description"> <p>A reference to the browser's <code>window</code> object. While <code>window</code> is globally available in JavaScript, it causes testability problems, because it is a global variable. In angular we always refer to it through the <code>$window</code> service, so it may be overridden, removed or mocked for testing.</p> <p>Expressions, like the one defined for the <code>ngClick</code> directive in the example below, are evaluated with respect to the current scope. Therefore, there is no risk of inadvertently coding in a dependency on a global value in such an expression.</p> </div> <div> <h2 id="example">Example</h2><p> <div> <a ng-click="openPlunkr('examples/example-example111')" class="btn pull-right"> <i class="glyphicon glyphicon-edit"> </i> Edit in Plunker</a> <div class="runnable-example" path="examples/example-example111" module="windowExample"> <div class="runnable-example-file" name="index.html" language="html" type="html"> <pre><code><script> angular.module('windowExample', []) .controller('ExampleController', ['$scope', '$window', function($scope, $window) { $scope.greeting = 'Hello, World!'; $scope.doGreeting = function(greeting) { $window.alert(greeting); }; }]); </script> <div ng-controller="ExampleController"> <input type="text" ng-model="greeting" /> <button ng-click="doGreeting(greeting)">ALERT</button> </div></code></pre> </div> <div class="runnable-example-file" name="protractor.js" type="protractor" language="js"> <pre><code>it('should display the greeting in the input box', function() { element(by.model('greeting')).sendKeys('Hello, E2E Tests'); // If we click the button it will block the test runner // element(':button').click(); });</code></pre> </div> <iframe class="runnable-example-frame" src="examples/example-example111/index.html" name="example-example111"></iframe> </div> </div> </p> </div>