类型'<< custom component =“” name =“” >>'的参数不能分配给类型'Type << custom component =“” name =“” >>'

时间:2019-05-09 17:28:04

标签: typescript bootstrap-modal angular7

这是我遇到的错误。我知道某种类型的参数不匹配,但是我无法弄清楚它发生在堆栈中的哪个位置。

Argument of type 'ModalUserInfoComponent' is not assignable to 
parameter of type 'Type<ModalUserInfoComponent>'.
Type 'ModalUserInfoComponent' is missing the following properties from 
type 'Type<ModalUserInfoComponent>': apply, call, bind, prototype, and 
5 more.

我已经设置了stackblitz来显示问题。该功能仅部分起作用(我假设由于没有传递必要的表单生成器数据,因为此问题以某种方式阻止了它。)

您会在stackblitz中注意到,模态仅传递名字和姓氏,其余的都不存在。

还有另一个错误,我很确定它是相关的,但是我还没有研究。

Error: "ExpressionChangedAfterItHasBeenCheckedError: Expression has 
changed after it was checked. Previous value: 'form: undefined'. 
Current value: 'form: [object Object]'. It seems like the view has been 
created after its parent and its children have been dirty checked. Has 
it been created in a change detection hook ?"

1 个答案:

答案 0 :(得分:0)

好的-解决此问题的方法是:

public contentComponent: Type<ModalVariants>;

代替:

public contentComponent: <ModalVariants>;

这就是我所拥有的。

相关问题