具有构造函数参数的Nativescript注册表项

具有构造函数参数的Nativescript注册表项,nativescript,angular2-nativescript,Nativescript,Angular2 Nativescript,有人能帮我登记吗?我正在尝试注册一个在构造函数中包含服务的元素。我有以下代码: export class CardComponent extends ContentView implements OnInit{ constructor(private componentFactoryResolver: ComponentFactoryResolver) { super(); } ... } registerElement('app-card', () => CardCo

有人能帮我登记吗?我正在尝试注册一个在构造函数中包含服务的元素。我有以下代码:

export class CardComponent extends ContentView implements OnInit{

  constructor(private componentFactoryResolver: ComponentFactoryResolver) {
    super();
  }
...
}

registerElement('app-card', () => CardComponent);
我得到一个错误TS2322:Type'typeof CardComponent'不可分配给Type'ViewClass'。

registerElement被指定用于NativeScript UI元素,您可以从基本视图或其任何子体(如ContentView)扩展的任何内容

但是这些UI元素不能有Angular的生命周期挂钩或依赖注入。我想你是想把它们混在一起,这是不可能的


如果您愿意为自定义UI元素提供广泛的角度支持,那么您应该编写一个单独的角度组件来继承自定义UI元素。类似于vs.

如果是这种情况,我将如何在tns.html文件中使用角度组件?我尝试只包含它,但它被忽略了,这是当我发现并尝试registerElement时。对于Angular组件,您只需在模块中声明它,并在HTML中使用选择器。如果对你不起作用,请共享一个可以复制该问题的游乐场。