Skip to content

Instantly share code, notes, and snippets.

@ericz
Created May 28, 2014 21:57
Show Gist options
  • Save ericz/2276a0da3134baef1e79 to your computer and use it in GitHub Desktop.
Save ericz/2276a0da3134baef1e79 to your computer and use it in GitHub Desktop.
#
# as
#
# When added as attribute to custom directive, exposes the isolate scope of the directive to parent scope
#
# Attributes:
# as: Name to save isolate scope as on parent scope
##
# Example:
###
<element
as="testPopup">
</element>
# The isolate scope of popup is now exposed as $scope.testPopup on parent
###
module.exports = (app) ->
app.directive('as', () ->
component =
restrict: 'A'
link: (scope, element, attrs) ->
scope[attrs.as] = element.isolateScope()
)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment