代码之家  ›  专栏  ›  技术社区  ›  Ebuall

角度组件的类型

  •  17
  • Ebuall  · 技术社区  · 8 年前

    我可以将角度组件类称为类型吗?我看到了离子的用途 any

    我看到了这个问题,但组件在构造函数中没有任何共同点: Passing class as parameter causes "is not newable" error

    4 回复  |  直到 8 年前
        1
  •  7
  •   Olexandr Polishchuk    5 年前

    ComponentType<T> 也许这会有帮助。

    import { ComponentType } from '@angular/cdk/overlay'; 
    
        2
  •  4
  •   Ebuall    7 年前

    事实证明,这在TypeScript中现在是不可能的。装饰器不能更改类的类型,这意味着它们对于类型系统是不可见的。

        3
  •  3
  •   diopside    8 年前

    请参见此处: https://angular.io/api/core/ComponentRef

     import { Directive } from '@angular/core'
     import { MyNavigatorComponent } from '../components/my-nav.component'
    
     constructor (private navigator: MyNavigatorComponent) {
    
        4
  •  0
  •   Arun Saini    3 年前

    发件人: https://angular.io/api/core/ComponentRef

    类型的一个示例是MyCustomComponent类,它在JavaScript中由MyCustomComponent构造函数表示。

    import { Type } from "@angular/core";
    
    export type MyDynamicComponentType = Type<any>;
    
    推荐文章