如何可能,添加一个辅助动作(垫-图标-按钮)在垫选择列表内的垫-列表-选项元素。
目前,所有项目都被添加到垫子列表-文本div中。
(https://stackblitz.com/edit/angular-dwac7y):示例
<mat-selection-list [(ngModel)]="selectedOptions">
<mat-list-option *ngFor="let item of items;" [value]="item.id" [disableRipple]="true">
<mat-icon matListAvatar>person</mat-icon>
<h3 matLine> {{item.name}}</h3>
<p matLine>
{{item.details}}
</p>
<button mat-icon-button (click)="onEdit($event, item)">
<mat-icon>edit</mat-icon>
</button>
</mat-list-option>
</mat-selection-list>发布于 2018-12-18 10:31:18
你可以这样做。
<h2>Selection-List with secondary action:</h2>
<mat-selection-list [(ngModel)]="selectedOptions">
<mat-list-option *ngFor="let item of items;" [value]="item.id" [disableRipple]="true">
<div style="display:flex; justify-content:space-between;align-items:center">
<div style="display:flex;align-items:center">
<mat-icon matListAvatar>person</mat-icon>
<div style="display:flex; flex-direction:column">
<div>
<h3 matLine> {{item.name}}</h3>
</div>
<div style="margin-top:-30px">
<p matLine>
{{item.details}}
</p>
</div>
</div>
</div>
<div>
<button mat-icon-button (click)="onEdit($event, item)">
<mat-icon>edit</mat-icon>
</button>
</div>
</div>
</mat-list-option>
</mat-selection-list>但下面的风格..。
<div style="margin-top:-30px">不是一个很好的解决办法。

发布于 2020-07-11 00:23:51
我觉得这个活动应该是这样的。
onEdit(event, item){
event.stopPropagation();
} https://stackoverflow.com/questions/53815547
复制相似问题