1.0.1 • Published 5 years ago

ng-inject v1.0.1

Weekly downloads
19
License
BSD
Repository
github
Last release
5 years ago

ng-inject

NPM travis-ci

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