5.0.2 • Published 1 year ago
static-injector v5.0.2
| 中文 | English |
|---|
Introduction
- Angular dependency injection standalone version
- The usage method is completely consistent with Angular's dependency injection
- No transformer required
- 0 dependencies
- Remove Decorator
@Injectable()=>static injectOptions={}@Inject() xx=>xx=inject()@Optional()=>xx=inject(token,{optional:true}) JS/TSSupport
Source
- Angular 18.0.0
Usage
- Create a first level dependency injector with
Injector.create
import { Injector, inject } from 'static-injector';
class Main {
child = inject(Child);
}
class Child {
output() {
return 'hello world';
}
}
let injector = Injector.create({ providers: [Main, Child] });
const instance = injector.get(Main);
console.log(instance.child.output());Different from injection-js
injection-jsbelongs to dynamic dependency injection and is a version used before Angular5. Currently no longer updatedThe two are basically interchangeable (the details need to be adjusted)
Support the use of
injectduring construction
No Decorator
- The original use of
@Injectable()to pass parameters has been changed tostatic injectOptions={}. If there are no parameters, there is no need to set them - Originally,
@Optional,@SkipSelf,@Self, please use the second pass parameter ofinjectinstead
Test
- Partially conducted unit testing to ensure that most functions are functioning properly
- Because most of the code itself is extracted from Angular, stability is definitely guaranteed
Sync
- Currently, the synchronization logic has been refactored and modified using
@code-recycle/clito ensure consistency with the official version ofangular
Examples
5.0.2
1 year ago
5.0.1
1 year ago
5.0.0
1 year ago
5.0.0-alpha.0
1 year ago
4.0.1
2 years ago
4.0.0
2 years ago
4.0.2
2 years ago
3.0.0
2 years ago
2.2.1
2 years ago
2.2.0
2 years ago
2.1.1
3 years ago
2.1.0
3 years ago
2.0.0
3 years ago
1.0.10
4 years ago
1.0.9
4 years ago
1.0.8
4 years ago
1.0.7
4 years ago
1.0.6
4 years ago
1.0.5
4 years ago
1.0.4
4 years ago
1.0.3
4 years ago
1.0.2
4 years ago
1.0.1
4 years ago
1.0.0
4 years ago