Skip to content

Instantly share code, notes, and snippets.

@cmartin81
Created July 28, 2015 22:43
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 cmartin81/42c713be3034ead79799 to your computer and use it in GitHub Desktop.
Save cmartin81/42c713be3034ead79799 to your computer and use it in GitHub Desktop.
How to use ng-decorator module
import {Factory, Directive, Provider, Service, Controller} from 'ng-decorators'
@Factory(['$window']) //or Directive or Provider or Service or Controller
class FooBar{
constructor(win){ //if you need to access the injected object it will be passed into the constructor
console.log(win.location.host)
}
logOrigin(){
console.log(this.$window.origin); //all the injected values will be auto injected to the class under this.<injected object>
}
}
app.factory('FooBarService', FooBar);
// or app.directive('FooBarService', FooBar);
// or app.service('FooBarService', FooBar);
// you see my point....
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment