I want the button disabled if the user has not filled the input fields. I added a condition (name.value.length === 0 || email.value.length === 0) This disables the button on load but when values are input in the text fields the disabled is not removed.
Here is my code:
<section class="container col-md-12 col-md-offset-3">
<h1>Add Users</h1>
<form class="form-inline">
<div class="form-group">
<label for="exampleInputName2">Name</label>
<input type="text" class="form-control" id="exampleInputName2" placeholder="Jane Doe" #name>
</div>
<div class="form-group">
<label for="exampleInputEmail2">Email</label>
<input type="email" class="form-control" id="exampleInputEmail2" placeholder="jane.doe@example.com" #email>
</div>
<button type="submit" [disabled]="(name.value.length === 0 || email.value.length === 0)" class="btn btn-default" (click)="getValues($event, name, email)">Add Data</button>
</form>
</section>
<section class="container">
<h3>Users Details</h3>
<table class="table">
<thead>
<tr>
<th class="col-md-6">Name</th>
<th class="col-md-6">Email</th>
</tr>
</thead>
<tbody>
<tr *ngFor="let data of dataArr">
<td>{{data.name}}</td>
<td>{{data.email}}</td>
</tr>
</tbody>
</table>
</section>