这是“我的文件夹”用户界面,当我单击或选择任何一个文件夹时,我想用绿色突出显示该特定文件夹,第二个问题是我将鼠标悬停在任何其他文件夹上,我想用黄色突出显示该文件夹。每个文件夹都有其不同的folderid
<div *ngFor="let folder of folderObjs (dblclick)="addNewFolderRoute(folder.folderid)">
<mat-icon>folder</mat-icon>
<span>{{folder.folderName}}</span>
</div>
答案 0 :(得分:3)
尝试一下
<div *ngFor="let folder of folderObjs" (dblclick)="addNewFolderRoute(folder.folderid)" (click)="activeFolder=folder" class="folder" [class.green]="folder==activeFolder">
<mat-icon>folder</mat-icon>
<span>{{folder.folderName}}</span>
</div>
和CSS
.folder:hover {
background:yellow;
}
.folder.green {
background:green;
}