我有一个场景,其中我只需要在Mat Multi Select中选择选项。当前,我正在添加一个按钮以及选项,并为选择单个项目添加了功能。我面临的问题是文本仅附加了该选项。 这是代码剪辑:
<mat-select
[formControl]="selectionControl" (selectionChange)="selectionChange($event.value)" multiple
>
<mat-option class="position-relative options-wrapper"
*ngFor="let version of [1,2,3,4,5,6,7,8,9,10] [value]="version">
<span>{{version}}</span>
<button mat-button class="position-absolute only-btn" style="top:5px; right: 0px;"
>Only</button>
</mat-option>
</mat-select>
任何帮助解决此问题的人都非常感谢。
<mat-select
[formControl]="selectionControl" (selectionChange)="selectionChange($event.value)" multiple
>
<mat-option class="position-relative options-wrapper"
<button mat-button class="position-absolute only-btn" style="top:5px; right: 0px;"
>Only</button>
</mat-option>
<mat-option class="position-relative options-wrapper"
*ngFor="let version of [1,2,3,4,5,6,7,8,9,10] [value]="version">
<span>{{version}}</span>
</mat-option>
</mat-select>
仅为按钮创建一个单独的
mat-option
,不要将其放入循环中。但老实说,有一个按钮之类的选择很奇怪。