[英]What is the type for array of different modules in angular?
In angular 5 core module I'm importing external and internal modules as well. 在角度5核心模块中,我也导入外部和内部模块。
So, I created an array of type any
to hold all module objects. 所以,我创建了一个类型为
any
的数组来保存所有模块对象。 I used that array variable in imports and exports. 我在导入和导出中使用了该数组变量。 My question is instead of
any
is there are other types we have? 我的问题是,而不是
any
的是,有其他类型,我们有吗? If So, for MODULES and COMPONENTS what type should come? 如果是这样,对于MODULES和COMPONENTS应该采用什么类型?
const MODULES: any[] = [
BrowserModule,
BrowserAnimationsModule,
HttpClientModule,
RouterModule,
];
const COMPONENTS: any[] = [
HeaderComponent
];
const PROVIDERS: Provider[] = [
NotifyService,
RouterHelpers
];
@NgModule({
imports: [
...MODULES,
],
declarations: [
...COMPONENTS,
],
providers: [
...PROVIDERS
],
exports: [
...MODULES,
...COMPONENTS,
]
})
export class CoreModule {
}
from NgModule doc 来自NgModule doc
Provider[]
Provider[]
Array<Type<any> |any[]>
Array<Type<any> |any[]>
Array<Type<any> | ModuleWithProviders |any[]>
Array<Type<any> | ModuleWithProviders |any[]>
Array<Type<any> | ModuleWithProviders |any[]>
Array<Type<any> | any[]>
Array<Type<any> | any[]>
Array<Type<any> | any[]>
Array<Type<any> | any[]>
Array<Type<any> | any[]>
Array<Type<any> | any[]>
Using type any[]
for modules and components is valid. 对模块和组件使用
any[]
类型是有效的。 If you want to use something else, you can refer to the NgModule
interface, which uses 如果您想使用其他东西,可以参考使用的
NgModule
接口
Array<Type<any> | any[]>;
for component declarations Array<Type<any> | ModuleWithProviders | any[]>;
for module imports Type
is a class from the angular framework ( doc ) Type
是角度框架( doc )中的一个类
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.