This docs describe many features of the library, but not all. Use source to learn InjectorJS better.
For installation read related chapter.
Online working version of fol;owing examples is available on plunker: http://plnkr.co/edit/SDXdO5. Feel free to play around with it!
Definition of simple objects (parameters):
console; // falseinjector;injector;console; // true
Defition of objects by factory functions:
Factory functions has access to current injector making it possible to references to other objects (inject dependencies). Objects are created only when you require them. These cause to that order of the definitions does not matter and there is no performance penalty.
You can define several objects in one set method call:
You can add object factory to injector to simplify creation of common type objects. Before creation object value will be passed to appropriate object factory:
injector;injector;console; // 300injector;injector;console; // hello world !
As you see object factory can be a function or an object with create method. By default there are 3 object factories:
injector;var person = injector;console; // 'Bob'console; // 10
Copyright (c) 2013 Aleksey Podskrebyshev. Licensed under the MIT license.