|
1 | | -<ng-content select="[mat-list-avatar],[matListAvatar],[mat-list-icon],[matListIcon]"></ng-content> |
2 | | - |
3 | | -<!-- If lines were explicitly given, use those as the text. --> |
4 | | -<ng-container *ngIf="lines.length"> |
5 | | - <span class="mdc-list-item__text"><ng-content select="[mat-line],[matLine]"></ng-content></span> |
6 | | -</ng-container> |
7 | | - |
8 | | -<!-- |
9 | | - If lines were not explicitly given, assume the remaining content is the text, otherwise assume it |
10 | | - is an action that belongs in the "meta" section. |
11 | | ---> |
12 | | -<span [class.mdc-list-item__text]="!lines.length" [class.mdc-list-item__meta]="!!lines.length"> |
| 1 | +<!-- Divide content into templates --> |
| 2 | + |
| 3 | +<ng-template #prefix> |
| 4 | + <ng-container *ngIf="checkboxPosition === 'after' else checkbox" [ngTemplateOutlet]="icons"> |
| 5 | + </ng-container> |
| 6 | +</ng-template> |
| 7 | + |
| 8 | +<ng-template #suffix> |
| 9 | + <span class="mdc-list-item__meta"> |
| 10 | + <ng-container *ngIf="checkboxPosition === 'after' else icons" [ngTemplateOutlet]="checkbox"> |
| 11 | + </ng-container> |
| 12 | + <ng-container [ngTemplateOutlet]="actions"></ng-container> |
| 13 | + </span> |
| 14 | +</ng-template> |
| 15 | + |
| 16 | +<ng-template #checkbox> |
| 17 | + <span class="mdc-list-item__graphic"> |
| 18 | + <mat-pseudo-checkbox></mat-pseudo-checkbox> |
| 19 | + </span> |
| 20 | +</ng-template> |
| 21 | + |
| 22 | +<ng-template #icons> |
| 23 | + <ng-content select="[mat-list-avatar],[matListAvatar],[mat-list-icon],[matListIcon]"></ng-content> |
| 24 | +</ng-template> |
| 25 | + |
| 26 | +<ng-template #text> |
| 27 | + <span class="mdc-list-item__text"> |
| 28 | + <ng-content *ngIf="lines.length else unsortedContent" select="[mat-line],[matLine]"> |
| 29 | + </ng-content> |
| 30 | + </span> |
| 31 | +</ng-template> |
| 32 | + |
| 33 | +<ng-template #actions> |
| 34 | + <ng-container *ngIf="lines.length" [ngTemplateOutlet]="unsortedContent"></ng-container> |
| 35 | +</ng-template> |
| 36 | + |
| 37 | +<ng-template #divider> |
| 38 | + <ng-content select="mat-divider"></ng-content> |
| 39 | +</ng-template> |
| 40 | + |
| 41 | +<ng-template #unsortedContent> |
13 | 42 | <ng-content></ng-content> |
14 | | -</span> |
| 43 | +</ng-template> |
| 44 | + |
| 45 | +<!-- Arrange the templates in the right order --> |
15 | 46 |
|
16 | | -<ng-content select="mat-divider"></ng-content> |
| 47 | +<ng-container [ngTemplateOutlet]="prefix"></ng-container> |
| 48 | +<ng-container [ngTemplateOutlet]="text"></ng-container> |
| 49 | +<ng-container [ngTemplateOutlet]="suffix"></ng-container> |
| 50 | +<ng-container [ngTemplateOutlet]="divider"></ng-container> |
0 commit comments