Skip to content

Instantly share code, notes, and snippets.

@Luxiyalu
Last active August 29, 2015 14:07
Show Gist options
  • Save Luxiyalu/18286905f3fd67947f92 to your computer and use it in GitHub Desktop.
Save Luxiyalu/18286905f3fd67947f92 to your computer and use it in GitHub Desktop.
AngularJS Directive: Resize
# dependency: jQuery
app.directive 'resize', ($window) ->
restrict: 'A'
($scope, $element, $attr) ->
win = angular.element($window)
$scope.$watch ->
w: win.width()
h: win.height()
, (newVal, oldVal) ->
$scope.windowWidth = newVal.w
$scope.windowHeight = newVal.h
, true # specify 'true' to enable deep dirty check
win.bind 'resize', ->
$scope.$apply()
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment