Created
July 28, 2015 22:43
-
-
Save cmartin81/42c713be3034ead79799 to your computer and use it in GitHub Desktop.
How to use ng-decorator module
This file contains hidden or 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
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