Skip to content

Instantly share code, notes, and snippets.

@ladas-larry
Created August 16, 2017 05:24
Show Gist options
  • Save ladas-larry/8b8fba1e4305c600100215abc42cd1be to your computer and use it in GitHub Desktop.
Save ladas-larry/8b8fba1e4305c600100215abc42cd1be to your computer and use it in GitHub Desktop.
//Dependency injection
// the Module object
var Module = function (someService) {
this.someService = someService;
};
Module.prototype.do = function () {
this.someService.doSomething();
};
// configuring the injector
Injector.add('someService', new SomeService());
// retrieving the module instance with the SomeService being injected
var module = Injector.get(Module);
module.do();
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment