Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

angularjs $window.height is undefined

Tags:

angularjs

$window.height is undefined. Where is the problem?

FoodSearchControllers.controller('homeCtrl', ['$scope', '$http', '$window', 'filterArgs', function($scope, $http, $window, filterArgs) {   $scope.popupHeight = $window.height;   console.log($scope.popupHeight); }]); 
like image 457
Rokas Avatar asked Dec 07 '13 11:12

Rokas


People also ask

How to get Window innerHeight?

To obtain the height of the window minus its horizontal scroll bar and any borders, use the root <html> element's clientHeight property instead. Both innerHeight and innerWidth are available on any window or any object that behaves like a window, such as a tab or frame.

What is$ Window in AngularJS?

A 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 AngularJS we always refer to it through the $window service, so it may be overridden, removed or mocked for testing.

What does Window innerWidth return?

The read-only Window property innerWidth returns the interior width of the window in pixels. This includes the width of the vertical scroll bar, if one is present. More precisely, innerWidth returns the width of the window's layout viewport.

What is angular Window?

The WindowService is an Angular service providing API calls, which are used to create Window instances dynamically. This means that the service helps create Window instances from TypeScript based on user interactions and without the need to define the component in a template.


1 Answers

$window is a wrapper for Window , and Window has no height property . You can use innerHeight instead, like: $scope.popupHeight = $window.innerHeight;

like image 142
Ivan Chernykh Avatar answered Oct 14 '22 09:10

Ivan Chernykh