I have a submit button in my form, i am trying to disable it until all the text-boxes are filled. Its not working after page is refreshed or loaded for the first time in browser. If i perform any other operation in the same page and then open this add detail pop up it is disabled. Help will be much appreciated.
component
form: FormGroup;
constructor(private fb: FormBuilder) {
this.createForm();
}
createForm() {
this.form = this.fb.group({
name: ['', Validators.required],
addrs: ['', Validators.required],
});
}
HTML file
<div id="details">
<form [formGroup]="form" (ngSubmit)="addDetails()" name="form" novalidate>
<div class="form-group">
<label for="name">Name</label><input type="text"
class="form-control" id="name" placeholder="Please Enter Name"
formControlName="name" >
</div>
<div class="form-group">
<label for="addrs">Address</label><input type="text"
class="form-control" id="addrs"
placeholder="Please Enter Address" formControlName="addrs" >
<button type="submit" [disabled]="form.invalid || loading"
class="btn btn-success">Submit</button>
<br>
<div *ngIf="loading" class="alert alert-success box-msg" role="alert">
<strong>Added Successfully</strong>
</div>
</form>
</div>
angular4-httpclientformControlName="Name"should beformControlName="name", no?