Wednesday, July 8, 2015

$window in AngularJS

$window provides a shortcut to access the browsers window object’s in AngularJS, using $window we can access the properties and events of the browser’s window object.

The following is the syntax to access $window property using AngularJS
$window.<windows property/event>

The following example shows how to get the browser window’s  width and height properties using $window

<html ng-app>
    <meta charset="utf-8">
    <title>AngularJS - $window Basic</title>
    <script src="angular.min.js"></script>
      function winController($scope, $window){
              $scope.Width = $window.innerWidth;
              $scope.Height = $window.innerHeight;
          <div ng-controller="winController">
                   Width: {{Width}} <br/>
                   Height: {{Height}} <br/>


Search Flipkart Products:

No comments: