Dependency Injections
@DependencyInjection.Inject(injectable:InjectableClass | Symbol)#
:InjectableClass | Symbol
This annotation allow to inject a service defined in the module, or a defined Service defined by using the Dependency Injection Service.
Parameters
| Name | Optional | Type | Defaults | Description | ||
|---|---|---|---|---|---|---|
| injectable | No | InjectableClass | Symbol | Injectable Class or Symbol from declared providers in modules. | |||
Example
import DependencyInjection from '@zerooneit/expressive-tea/services/DependencyInjection';
class TestService { test() { console.log('Test'); }}
DependencyInjection.setProvider(TestService);
class TestClass { @DependencyInjection.Inject(TestService) testService: TestService;}@DependencyInjection.InjectNamed(injectableName:String | Symbol)#
:String | Symbol
Same as Inject this is used to inject a service using how is named when added into the dependency injection container,
per default a Class Service constructor name is saved as a name.
Parameters
| Name | Optional | Type | Defaults | Description | ||
|---|---|---|---|---|---|---|
| injectableName | No | String | Symbol | Root Path | |||
Example
import DependencyInjection from '@zerooneit/expressive-tea/services/DependencyInjection';
class TestService { test() { console.log('Test'); }}
DependencyInjection.setProvider(TestService, 'aService');
class TestClass { @DependencyInjection.InjectNamed('aService') testService: TestService;}