angular-es
This is a helper library for developing Angular@1.x applications with ES7 decorators.
Benefits
- Perfectly runs with jspm, webpack & babel
- Supports lazy loading & initialization with libraries like $ocLazyLoad
- Perfectly suits for
folder-by-feature
application structure - Simple in usage
Installation
npm install angular-es
Available decorators
- @Component
- @Config
- @Constant
- @Controller
- @Decorator
- @Directive
- @Factory
- @Filter
- @Inject
- @InjectAsProperty
- @Module
- @Provider
- @Run
- @Service
- @Value
Usage
Component
Define component
; @@@ myService; { thismyService = myService; }
Config
Add config block
; @@Config@ { }
Constant
Register constant
; @@ foo = 'foo'; bar = 'bar';
Controller
Register controller
; @@@ $myService; { this$myService = $myService; }
Decorator
Provide decorator
; @@@ { $delegatedecorated = true; return $delegate; } ;
Directive
Register directive
; @@@ $myService; restrict = 'A'; controllerAs = 'vm'; { this$myService = $myService; } @ { } { this$myService; }
Factory
Register factory
; static $q; static myService @@@ { TestModel$q = $q; TestModelmyService = myService; return TestModel; }
Filter
Register filter
; @@@ $q; { this$q = $q; return ::thisfilter; } { const $q = this$q; return input; }
Inject
Adds $inject
to target
; @ @ { super$rootScope; } @ { } @ static { }
InjectAsProperty
Injects provided dependencies as properties
; @@@ { return this; }
Module
Attaches target to specified angular module
@Module
decorator is required and it has to be present at the top level of target annotation block
Make sure that used angular module is already available
;; @@
Provider
Register provider
; @@ static config; { MyServiceProviderconfig = config; } @ return getConfig: getConfig ; { return $q; }
Run
Add run block
; @@Run@ { }
Service
Register service
; @@@ $http; { this$http = $http; }
Value
Register value
; @@ foo = 'foo'; bar = 'bar';