我在屏幕上填充了一个元素列表,只想在 ListView 中突出显示所选元素,请帮忙
<ion-list >
<button ion-item *ngFor="let route of Routes" (click)="selectCP(route)" >
{{route.Name}}
</button>
</ion-list>
最佳答案
使用 Angular 条件样式函数。
[class.stylename]="一些将返回 true 或 false 的条件语句"
例子:
<!-- This will probably go into your SCSS stylesheet -->
<style>
.highlight {
background-color: #FFFF33 !important;
}
</style>
<!-- In your HTML code -->
<ion-list >
<button ion-item [class.highlight]="route == 1" *ngFor="let route of Routes" (click)="selectCP(route)" >
{{route.Name}}
</button>
</ion-list>
关于css - 如何突出显示 ionic 列表中的选定元素,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/50632982/