Skip to content

Alternative declaration support #190

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Closed
dctdevelop opened this issue Aug 31, 2015 · 5 comments
Closed

Alternative declaration support #190

dctdevelop opened this issue Aug 31, 2015 · 5 comments

Comments

@dctdevelop
Copy link

Hey Guys,

I was noticing that there are hackish ways of implementing ng-annotate in compile-to-js languages, such as coffescript (i.e decalring a null statement)

While I believe that this is coffee-script's fault for not adding the comment on the declaration, I thought of a possible solution.

Is it possible to simply declare the $inject (as null, undefined, etc) property on the object we want annotated?

module.exports = ($scope)->
  $scope.foo = "foo"
  return

module.exports.$inject = null # [], undefined, etc. (falsey value for ng-annotate to populate)

ng-anotate would populate the field on this line. Based on the object in question.

Regards.

@dctdevelop
Copy link
Author

Should have looked more deeply into existing issues.
Apologies #81

@olov
Copy link
Owner

olov commented Aug 31, 2015

Did you try "ngInject"; at the beginning of the function you wanted annotated?

@dctdevelop
Copy link
Author

Yeah

I resolved to

null
###@ngInject###
module.exports = ($scope, ...)->
  ...

Without the null statement at the top, coffescript will place its required functions between the annotation or directive prologue (such when using _item in _array) syntax.

http://bit.ly/1MXR1YT

Regards

@olov
Copy link
Owner

olov commented Aug 31, 2015

Feel free to try the following instead:

module.exports = ($scope, ...) ->
    "ngInject";
    ....

@dctdevelop
Copy link
Author

I totally missed that in the docs, and also misunderstood it your comments. Apologies.

Thanks for the support.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants