Skip to content

Instantly share code, notes, and snippets.

@vojtajina
Created March 20, 2014 20:29
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save vojtajina/9673132 to your computer and use it in GitHub Desktop.
Save vojtajina/9673132 to your computer and use it in GitHub Desktop.
Annotations in ES5
// helper function, we can even ship these
define(['di/annotations'], function(annotations) {
var Inject = annotations.Inject;
var annotate = annotations.annotate;
return function inject(fn) {
var deps = Array.prototype.slice.call(arguments, 1);
var annotation = new Inject();
Inject.apply(annotation, deps);
annotate(fn, annotation);
};
});
define(['./inject-helper', 'foo'], function(inject, Foo) {
inject(MyController, Foo);
function MyController(foo) {
// ...
}
return MyController;
});
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment