Skip to content

Instantly share code, notes, and snippets.

@graywolf336
Created June 20, 2015 14:57
Show Gist options
  • Save graywolf336/ea57c7192d87e5a64ab7 to your computer and use it in GitHub Desktop.
Save graywolf336/ea57c7192d87e5a64ab7 to your computer and use it in GitHub Desktop.
screenHeight Directive - Changes the height of an element to the screen size
app.directive('screenHeight', ['$window', '$log', function($window, $log) {
return {
restrict: 'A',
link: function($scope, element, attrs) {
var changeHeight = function() {
$log.log('Setting the height of', element, 'to', $window.innerHeight);
element.css('height', $window.innerHeight + 'px');
}
changeHeight();
angular.element($window).bind('resize', changeHeight);
$scope.$on('destory', function() {
angular.element($window).unbind('resize');
});
}
}
}]);
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment