【发布时间】:2016-11-03 08:22:54
【问题描述】:
无法删除 ionic-2 中的动态组件。打字稿编译时出现异常
“通用类型 'ComponentRef' 需要 1 个类型参数”。
此外,在不使用 ionic2 的情况下使用相同的代码。 非常感谢您的帮助。 提前致谢。
class DynamicCmp {
_ref: ComponentRef;
_idx: number;
constructor(private resolver: ComponentResolver, private location: ViewContainerRef) { }
remove() {
this._ref.destroy();
}
add1() {
this.resolver.resolveComponent(DynamicCmp).then((factory: ComponentFactory<any>) => {
let ref = this.location.createComponent(factory, 0);
ref.instance._ref = ref;
ref.instance._idx = this._idx++;
});
}
}
异常:TypeScript 错误:....../home/home.ts(9,11): Erro r TS2314:通用类型“ComponentRef”需要 1 个类型参数。
【问题讨论】:
标签: angular ionic2 angular2-components