天天看點

關于Angular @Injectable的幾種測試情況

關于Angular @Injectable的幾種測試情況
關于Angular @Injectable的幾種測試情況
關于Angular @Injectable的幾種測試情況
關于Angular @Injectable的幾種測試情況
關于Angular @Injectable的幾種測試情況
關于Angular @Injectable的幾種測試情況
關于Angular @Injectable的幾種測試情況
關于Angular @Injectable的幾種測試情況
關于Angular @Injectable的幾種測試情況
關于Angular @Injectable的幾種測試情況
關于Angular @Injectable的幾種測試情況
關于Angular @Injectable的幾種測試情況

注解 @Injectable 的作用:

Determines which injectors will provide the injectable, by either associating it with an @NgModule or other InjectorType, or by specifying that this injectable should be provided in one of the following injectors:

‘root’ : The application-level injector in most apps.

‘platform’ : A special singleton platform injector shared by all applications on the page.

‘any’ : Provides a unique instance in each lazy loaded module while all eagerly loaded modules share one instance.

Marking a class with @Injectable ensures that the compiler will generate the necessary metadata to create the class’s dependencies when the class is injected.

@Injectable 的含義是,當被注解的 class 被注入時,編譯器會生成必要的中繼資料,以建立類的依賴。

繼續閱讀