I am trying to make a div on resize reach fill the entire height of the window minus a certain amount.
For some reason I get the following error:
ionic.bundle.js:26794 TypeError: w.height is not a function
at scope.getWindowDimensions (app.js:283)
at Scope.$digest (ionic.bundle.js:30230)
at Scope.$apply (ionic.bundle.js:30503)
at done (ionic.bundle.js:24824)
at completeRequest (ionic.bundle.js:25022)
at XMLHttpRequest.requestLoaded (ionic.bundle.js:24963)
However, if I remove my ionic.bundle.js from the header, it works. (note that I am using this in the browser)
Directive
.directive('resize', function ($window) {
return function (scope, element) {
var w = angular.element($window);
console.log(w);
scope.getWindowDimensions = function () { return { 'h': w.height(), 'w': w.width() }; };
scope.$watch(scope.getWindowDimensions, function (newValue, oldValue) {
scope.windowHeight = newValue.h;
scope.windowWidth = newValue.w;
scope.style = function (amount) { return { 'height': (newValue.h - amount) + 'px', 'width': (newValue.w - amount) + 'px' }; };
scope.height = function (amount) { return { 'height': (newValue.h - amount) + 'px' }; };
}, true);
w.bind('resize', function () { scope.$apply(); });
}
})
TEMPLATE
<div id="pageContent" ng-style="height(75)" resize>
Stuff here
</div>
CSS
#pageContent {
position: relative;
padding-bottom: 20px;
z-index: 2;
overflow: auto;
}