1
사용자가 입력 필드를 채우지 않은 경우 버튼을 비활성화하고 싶습니다. "(name.value.length === 0 || email.value.length === 0)"조건을 추가하여로드시 버튼을 비활성화하지만 텍스트 필드에 값을 입력하면 비활성화 됨이 제거되지 않음어떻게 입력 상자가 비어 있고 필드가 채워 졌을 때 버튼을 비활성화합니까?
<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="[email protected]" #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>
체크 폼이 유효하고 버튼에 disabled 속성을 추가하십시오. –
[disabled] = "! userName"으로 충분해야합니다. – Vega