2011-07-17 08:05:43 +00:00
|
|
|
'use strict';
|
|
|
|
|
|
2011-02-15 06:12:45 +00:00
|
|
|
/**
|
2011-11-10 06:23:36 +00:00
|
|
|
* @ngdoc object
|
2012-06-12 06:49:24 +00:00
|
|
|
* @name ng.$window
|
2011-02-15 06:12:45 +00:00
|
|
|
*
|
|
|
|
|
* @description
|
2011-02-14 18:17:04 +00:00
|
|
|
* A reference to the browser's `window` object. While `window`
|
2011-02-15 06:12:45 +00:00
|
|
|
* is globally available in JavaScript, it causes testability problems, because
|
|
|
|
|
* it is a global variable. In angular we always refer to it through the
|
|
|
|
|
* `$window` service, so it may be overriden, removed or mocked for testing.
|
|
|
|
|
*
|
|
|
|
|
* All expressions are evaluated with respect to current scope so they don't
|
|
|
|
|
* suffer from window globality.
|
|
|
|
|
*
|
|
|
|
|
* @example
|
|
|
|
|
<doc:example>
|
|
|
|
|
<doc:source>
|
2012-03-09 08:00:05 +00:00
|
|
|
<input ng-init="$window = $service('$window'); greeting='Hello World!'" type="text" ng-model="greeting" />
|
|
|
|
|
<button ng-click="$window.alert(greeting)">ALERT</button>
|
2011-02-15 06:12:45 +00:00
|
|
|
</doc:source>
|
|
|
|
|
<doc:scenario>
|
|
|
|
|
</doc:scenario>
|
|
|
|
|
</doc:example>
|
|
|
|
|
*/
|
2011-11-02 23:32:46 +00:00
|
|
|
function $WindowProvider(){
|
|
|
|
|
this.$get = valueFn(window);
|
|
|
|
|
}
|