简体   繁体   English

不同 Angular 组件阵列的 TypeScript 类型是什么?

[英]What is the TypeScript type of an array of different Angular components?

In my app there are a lot of various components.在我的应用程序中有很多不同的组件。 I would like to have an array of components.我想要一组组件。 There is no rule of what components can be in the array.数组中可以包含哪些组件没有规则。 The only rule is that these should be Angular components.唯一的规则是这些应该是 Angular 组件。

How to define properly a TypeScript type of an array of Angular components?如何正确定义 Angular 组件数组的 TypeScript 类型?

Something like:就像是:

myComponents: AngularComponent[];

Specifically what is the proper replacement for my imagined "AngularComponent" class?具体来说,我想象中的“AngularComponent”class 的正确替代品是什么?

There is an interface Component:有一个接口组件:

myComponents:Component[]

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM