Last active
August 29, 2015 14:00
-
-
Save 97jaz/11010512 to your computer and use it in GitHub Desktop.
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
# So, ideally I would replace boilerplate like: | |
$scope = $ctrl = null | |
beforeEach inject ($injector) -> | |
$scope = $injector.get("$rootScope") | |
$ctrl = $injector.get("$controller") | |
# ... with something like: | |
beforeEach injected("$rootScope", "$controller") | |
################## | |
## Ah, no -- sorry. The results here need to be bound outside of the beforeEach scope, | |
## so it would actually be something like: | |
injectBefore "$rootScope", "$controller" | |
################## | |
# However, since the output needs to be bound locally, this is impossible without (unhygienic) macros or | |
# lexical eval. (Lexical eval is evil, but it might actually work here...) | |
# Alternatively, I would replace the boilerplate with: | |
beforeEach -> [$scope, $ctrl] = injected("$rootScope", "$controller") | |
# ... where the issue is getting `injected` into the lexical environment. | |
# That requires either lexical eval or taking advantage of the fact that the | |
# global object (window) rather unfortunately serves as a kind of catch-all | |
# for the top of the lexical scope chain. | |
# Anyhow, it's clear that I *can* get at least the second of these two work, | |
# but I'm fairly convinced that it will require one of two unsavory options. | |
# The better way to do this would be to use a module system. | |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment