ng-inject
v1.0.1
Published
Decorator that wraps a class in an Angular 1.x DI injector for the given dependencies.
Downloads
24
Readme
ng-inject
Decorator that wraps a class in a DI injector for the given dependencies.
Dependencies are assigned to the prototype, and can be referenced from within the Class as this.$name
.
Usage
import inject from 'ng-inject';
// decorator takes a list of angular dependency names:
@inject('$scope', 'config')
class ExampleController {
constructor() {
// both `$scope` and `config` are injected via DI:
this.$scope.config = this.config;
}
otherMethod() {
this.$scope.value = 1;
}
}
License
BSD 3-Clause