>' 不可分配给类型为 'Type< 的参数>',typescript,bootstrap-modal,angular7"/>

首页 > 解决方案 > '< 类型的参数>' 不可分配给类型为 'Type< 的参数>'

问题描述

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

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 ?"

标签: typescriptbootstrap-modalangular7

解决方案


好的——这个问题的修复是:

public contentComponent: Type<ModalVariants>;

代替:

public contentComponent: <ModalVariants>;

这就是我所拥有的。


推荐阅读