angular.service.$window

Work In Progress This page is currently being revised. It might be incomplete or contain inaccuracies.

Description

Is reference to the browser's window object. While window 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.

Dependencies

Methods

Properties

Example

<input ng:init="greeting='Hello World!'" type="text" name="greeting" /> <button ng:click="$window.alert(greeting)">ALERT</button>