【发布时间】:2020-06-11 20:52:45
【问题描述】:
我有两个下拉菜单,它们是单击Retrieve 按钮时调用的函数的参数。我想要发生的是当两个下拉菜单都没有选择数据时,Retrieve 按钮被禁用。如果两个下拉菜单都有数据,那么我希望按钮正常运行。
这是我当前的html:
<div class="dropdown">
<div class="input-group">
<h4 class="sessionText">Session: </h4>
<select [(ngModel)]='sessionReportFilter.sessionName'
class="custom-select form-control-sm"
(change)='sessionDataChange($event)'
id="inputGroupSelect01">
<option [value]="null">Select session...</option>
<option *ngFor="let session of sessionData" [value]='session.sessionName'>
{{session.sessionName}}
</option>
</select>
</div>
<div class="input-group">
<h4 class="reportText">Report Date: </h4>
<select [(ngModel)]='sessionReportFilter.fileName' *ngIf='currentSession' class="custom-select form-control-sm" id="inputGroupSelect01">
<option [value]="null">Select report...</option>
<option *ngFor="let report of currentSession.reportFiles"
[value]="report">
{{report}}
</option>
</select>
<select *ngIf="currentSession === null" class="custom-select form-control-sm" id="inputGroupSelect01"></select>
</div>
<div>
<button type="button" class="btn btn-primary" disabled="disabled">Retrieve</button>
<button type="button" class="btn btn-primary" (click)="orderExceptionReportData()">Retrieve</button>
</div>
</div>
我怎样才能达到预期的效果?
【问题讨论】:
-
只有当用户从两个 ddls 中选择了值时,您才希望启用该按钮,否则,检索按钮将被禁用,对吗?
-
@FurqanS.Mahmoud 正确
标签: html angular angular-ng-if