Created
June 20, 2015 14:57
-
-
Save graywolf336/ea57c7192d87e5a64ab7 to your computer and use it in GitHub Desktop.
screenHeight Directive - Changes the height of an element to the screen size
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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