Skip to content

Instantly share code, notes, and snippets.

What would you like to do?
A generic window resize directive to which you can add to any element to call a function on your controller
.directive 'windowResize', ($window, $parse) ->
restrict: 'A'
link: (scope, element, attrs) ->
w = angular.element($window)
fn = $parse(attrs['windowResize'])
handler = (event) ->
scope.$apply ->
fn(scope, {$event:event})
w.bind 'resize', handler
scope.$on '$destroy', ->
w.unbind 'resize', handler
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
You can’t perform that action at this time.