Skip to content

Latest commit

 

History

History
62 lines (41 loc) · 1.43 KB

_README.adoc

File metadata and controls

62 lines (41 loc) · 1.43 KB

ng_di

Build Status

A Dependency Injection package taken from angular DI.

Usage

Create one of the examples shown below

Inject by Type

Create an Injector by using annotation @GenerateInjector and pass the List of types, then the generator will create the respective injector.

link:example/type.dart[role=include]

Full code:

link:example/type.dart[role=include]

Inject using @Inject() annotation

In this case you can specify the token corresponding to the dependency that will be injected. For example:

link:example/inject.dart[role=include]

Inject using @Optional() or @optional annotation

In this case we can mark dependencies as optional, so if the value is not injected then a null value is passed. For example:

link:example/optional.dart[role=include]

Inject using @Self() or @self annotation

In this case we can mark dependencies as self, so the injector should retrieve a dependency only from itself. For example:

link:example/self.dart[role=include]

Inject using @SkipSelf() or @skipSelf annotation

In this case we can mark dependencies as optional, so the dependency resolution should start from the parent injector. For example:

link:example/skip_self.dart[role=include]