$window
Injectable
window objectDescription
An injectable wrapper for window
object . Useful for
mocking a browser dependency in non-browser environment tests:
Example:
// value injectables are overriden
angular.module('demo', []).value('$window', {});
When combined with ng-inject directive, the wrapper also makes window object
directly accessible in the template scope.
Demo
<section ng-app>
<div ng-inject="$window"></div>
<button class="btn btn-dark" ng-click="$window.alert('click')">Alert</button>
</section>
Feedback
Was this page helpful?
Glad to hear it! Please tell us how we can improve.
Sorry to hear that. Please tell us how we can improve.