The $window
service provides a jQuery wrapper for a browser’s window
object, allowing you to access the window
object as you normally would from JavaScript. To illustrate this, the following code pops up a browser alert, using the alert()
method on the window
object. The message of the alert gets data from the $window.screen.availWidth
and $window.screen.availHeight
properties of the browser’s window
object:
var app = angular.module('myApp', []);
app.controller('myController', ['$scope', '$window',
function($scope, window) {
window.alert("Your Screen is:
" +
window.screen.availWidth + "X" + window.screen.availHeight);
}]);