ng-inject

Decorator that wraps a class in an Angular 1.x DI injector for the given dependencies.


Keywords
angular, es2015, es2016, es6, es7, decorator, inject, di
License
BSD-3-Clause
Install
npm install ng-inject@1.0.1

Documentation

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