Created
August 16, 2017 05:24
-
-
Save ladas-larry/8b8fba1e4305c600100215abc42cd1be to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//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