Only action === 'enable'
in if
is causing 'Cannot invoke an expression whose type lacks a call signature. Type '((value?: any, options?: Object)
=> void) | ((opts?: { onlySelf?: boolean; emitEvent?: boolean; }) => void)' has no compatible call signatures.' error in the line of formGroup.get
, if I remove this snippet on the if
the error does not happen.
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 <<<<<<<<<<<<
}
}
At other times I call the function.
this.act('reset');
this.act('enable');
this.act('disable');
//etc
formGroup initiation
const formGroup = this.formBuilder.group({
field1: [{ value: undefined, disabled: false }, Validators.compose([])],
field2: [
{ value: 'text' },
Validators.compose([Validators.required])
],
....
return formGroup