$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); }]);
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.
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.
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.
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.
$window
is a wrapper for Window
, and Window
has no height
property . You can use innerHeight
instead, like: $scope.popupHeight = $window.innerHeight;
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With