1
I am trying to validate a form that only receives a parameter, in this form I have a search button that should only be enabled after typing at least 5 letters, but is going wrong, pq the button initializes unlocked and when I start typing it locks and unlocks again when I type the 5 digits, I don’t use formGroup much, so I needed to know why it is starting as "True".
In short: the Valid form group should start as false, but is starting as true.
My TS:
this.formGroup = formBuilder.group({
nmFornecedor: ['', Validators.minLength(5)]
})
HTML:
<form [formGroup]="formGroup">
<ion-item>
<ion-label floating>Nome fornecedor</ion-label>
<ion-input type="text" formControlName="nmFornecedor" ></ion-input>
</ion-item>
<button ion-button (click)="teste()" [disabled]="!formGroup.valid">Resultado</button>
</form>