如果復選框被選中,我試圖顯示多個欄位,但我編碼它的方式到目前為止還沒有作業。目前,當我選中復選框時它什么也不做。我想在選中復選框后顯示輸入欄位。有人可以幫助我解決方案以及為什么我當前的代碼不起作用。
html
<mat-expansion-panel fluid [expanded]="true">
<mat-expansion-panel-header>
<mat-panel-title>
<h2 class="section-title">Header</h2>
</mat-panel-title>
<div class="row">
<mat-checkbox (click)="toggle()">Checkbox </mat-checkbox>
</div>
<div [hidden]="isHidden">
<mat-form-field appearance="fill">
<mat-label>Input</mat-label>
<input matInput>
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Select</mat-label>
<mat-select>
<mat-option value="one">First option</mat-option>
<mat-option value="two">Second option</mat-option>
</mat-select>
</mat-form-field>
<mat-form-field appearance="fill">
<mat-label>Textarea</mat-label>
<textarea matInput></textarea>
</mat-form-field>
</div>
</mat-expansion-panel>
ts
isHidden = false;
toggle() {
this.isHidden = !this.isHidden;
}
uj5u.com熱心網友回復:
您需要檢查mat-checkbox元素的API,它有changed輸出,而不是click,因此您可以使用此事件。這是一個例子
轉載請註明出處,本文鏈接:https://www.uj5u.com/net/376705.html
上一篇:提交按鈕和從mat-selectAngularMaterial中選擇的專案的條件
下一篇:在角度模板中顯示陣列元素
