【发布时间】:2019-09-07 16:28:04
【问题描述】:
只有if 中的action === 'enable' 导致'无法调用类型缺少调用签名的表达式。键入'((值?:任何,选项?:对象)
=> 无效)| ((opts?: { onlySelf?: boolean; emitEvent?: boolean; }) => void)' 没有兼容的调用签名。' formGroup.get 行中的错误,如果我删除这个 sn-p在if 上不会发生错误。
public act(action: string) {
this.formGroup.get('field1')[action]();
if (action === 'reset' || (this.userPermissions.field2 === true && action === 'enable')) {
this.formGroup.get('field2')[action](); //error here <<<<<<<<<<<<
}
}
其他时候我调用这个函数。
this.act('reset');
this.act('enable');
this.act('disable');
//etc
formGroup 启动
const formGroup = this.formBuilder.group({
field1: [{ value: undefined, disabled: false }, Validators.compose([])],
field2: [
{ value: 'text' },
Validators.compose([Validators.required])
],
....
return formGroup
【问题讨论】:
-
显示表单组启动
-
已编辑:formGroup 启动
标签: angular typescript