Look at the form well
<form #registerForm="ngForm" (ngSubmit)="onSubmit(registerForm)" class="col-lg-10" >
<p>
<label >Nome</label>
<input type="text" name="name" #name="ngModel" [(ngModel)]="user.name" class="form-control" required/>
<span *ngIf="!name.valid && name.touched">
O nome é obrigatório
</span>
</p>
<p>
<label >Sobrenome</label>
<input type="text" name="surname" #surname="ngModel" [(ngModel)]="user.surname" class="form-control" required/>
<span *ngIf="!surname.valid && surname.touched">
O sobrenome é obrigatório
</span>
</p>
<p>
<label >Email</label>
<input type="text" name="email" #email="ngModel" [(ngModel)]="user.email" class="form-control" required/>
<span *ngIf="!email.valid && email.touched">
O email é obrigatório
</span>
</p>
<p>
<label>Senha</label>
<input type="text" name="password" #password="ngModel" [(ngModel)]="user.password" class="form-control" required/>
<span *ngIf="!password.valid && password.touched">
A senha é obrigatório
</span>
</p>
<input type="submit" value="{{title}}" class="btn btn-primary" [disabled]="!registerForm.form.valid" />
</form>
</div>
Why was the registration button not disabled?
To know the value of the registerForm.form.valid if it is true or false I did the following ...
In the component file I put it like this;
onSubmit(form: NgForm) {
console.log(form);
}
And I checked the console as it would if it were like this;
AndIsubmittedtheformandgaveit;
The valid attribute was like true knowing that it should be like false
Where is it wrong?