[英]What does [indeterminate] property exactly do in Angular Material components?
我已經使用了一些Angular Material組件,我在網上搜索了一個名為[indeterminate]
的屬性,但沒有很好的解釋它究竟是做什么的。 那么,你能告訴我它在下面的例子中做了什么嗎?
<section class="example-section">
<mat-checkbox class="example-margin">Check me!</mat-checkbox>
<mat-checkbox class="example-margin" [disabled]="true">Disabled</mat-checkbox>
</section>
<section class="example-section">
<span class="example-list-section">
<mat-checkbox class="example-margin"
[checked]="allComplete"
[indeterminate]="someComplete()"
(change)="setAll($event.checked)">
{{task.name}}
</mat-checkbox>
</span>
<span class="example-list-section">
<ul>
<li *ngFor="let subtask of task.subtasks">
<mat-checkbox [(ngModel)]="subtask.completed"
[color]="subtask.color"
(ngModelChange)="updateAllComplete()">
{{subtask.name}}
</mat-checkbox>
</li>
</ul>
</span>
</section>
indeterminate
意味着復選框既未選中也未選中,有點中間。
正如您從文檔中看到的那樣,它看起來像這樣:
例如,當您有一個可以選中/取消選中的內容列表,並且它們與父項(例如 TreeView)分組時,這通常會使用。
如果所有子項都被選中,則父項將被檢查,如果其所有子項都未選中,則未選中,如果其某些子項被選中,則indeterminate
。
文檔也有一個例子:
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.