I'm trying to get this to work but I don't know how, I have several inputs that are only displayed when the user needs them.But if they are activated, it must be necessary to fill them. So i got this
component.ts
dataForm = new FormControl({
myInput: new FormControl(null, Validators.required)
})
component.html
<form [formGroup]="dataForm">
<input formControlName="myInput" type="number" *ngIf="inputActive">
<button type="submit" [disabled]="!dataForm.valid">
</form>
The problem I have is that when the inputActive variable is false and the input is not shown, the button is still disabled because the field is empty
And I want that when the input is not shown, its validators are not executed so that the button is enabled
Can anyone help me to achieve this?