ng-decorators
Set of angular decorator for creating Services, controllers, factories that also inject objects at the same time
Inspiration
The business logic for transforming the ES6 classes to support angular 1.x syntaks is from Michael Bromley project angular-es6.
Please read his article Exploring ES6 Classes In AngularJS 1.x
Install
$ npm install --save ng-decorators
Usage
@ //or Directive or Component or Provider or Service or Controller { //if you need to access the injected object it will be passed into the constructor console this; //careful! dependencies not yet injected so logOrigin will log 'logOrigin, undefined' } //use init instead of constructor as a general rule as dependencies are injected post construction { console; //init method automatically invoked this; //dependencies will be injected so logOrigin will log 'logOrigin, [$window]' } { console; //all the injected values will be auto injected to the class under this.<injected object> } app;// or app.directive('FooBarService', FooBar);// or app.service('FooBarService', FooBar);// you see my point....
Note
You need to run babel with the option 'es7.decorators' enabled.
Test
Let's start with a simple Factory
; @ { thiscache = ; } return thiscache; thiscache; ;
Then make an Angular module
;; let thingModule = angular ; ;
And top it off with a wee test
; ;