static-injector 5.0.0 → 5.0.1

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
Files changed (2) hide show
  1. package/package.json +1 -1
  2. package/readme.md +10 -12
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "static-injector",
3
- "version": "5.0.0",
3
+ "version": "5.0.1",
4
4
  "description": "Angular 依赖注入独立版本;Angular dependency injection standalone version",
5
5
  "keywords": [
6
6
  "angular",
package/readme.md CHANGED
@@ -21,21 +21,19 @@
21
21
 
22
22
  - Create a first level dependency injector with `Injector.create`
23
23
  ```ts
24
- import { Injector } from 'static-injector';
24
+ import { Injector, inject } from 'static-injector';
25
25
 
26
- export class FirstClass {
27
- constructor() {}
28
- hello() {
29
- return 'hello';
26
+ class Main {
27
+ child = inject(Child);
28
+ }
29
+ class Child {
30
+ output() {
31
+ return 'hello world';
30
32
  }
31
33
  }
32
-
33
- let injector = Injector.create({
34
- providers: [{ provide: FirstClass }],
35
- });
36
- let instance = injector.get(FirstClass);
37
- console.log(instance.hello());
38
-
34
+ let injector = Injector.create({ providers: [Main, Child] });
35
+ const instance = injector.get(Main);
36
+ console.log(instance.child.output());
39
37
  ```
40
38
 
41
39
  # Different from `injection-js`