当用户将鼠标悬停在列表项上时,我希望显示一个按钮。当用户离开列表项时,我希望该按钮不再显示。
我发现了一个mouseenter事件和一个mouseleave事件。 .html
除了声明这些函数,我不知道如何针对列表项中的按钮进行定位,以便根据用户是否进入了列表项块或离开来显示和隐藏它。
我发现了一个mouseenter事件和一个mouseleave事件。 .html
<mat-list-item (mouseenter)="enter($event)" (mouseleave)="leave($event)" class="chat-message-body" *ngIf="auth._id !== message.author._id" fxLayoutAlign=""
dir="ltl">
<div matLine>
<b>{{message.author.profile.username}} </b>
<span>{{message.created_at | date:'shortTime'}} </span>
</div>
<button mat-icon-button>
<mat-icon aria-label="">keyboard_arrow_down</mat-icon>
</button>
<span matLine> {{message.body}} </span>
<img matListAvatar class="img-box" src="http://via.placeholder.com/30x30" alt="...">
</mat-list-item>
.ts
enter(e) {
console.log("enter");
}
leave(e) {
console.log("leave");
}
除了声明这些函数,我不知道如何针对列表项中的按钮进行定位,以便根据用户是否进入了列表项块或离开来显示和隐藏它。
ngFor
中?这听起来有歧义。 - Armen Vardanyan