How to use mouseover and mouseout in Angular 6

后端 未结 8 1035
既然无缘
既然无缘 2020-12-14 00:09

I have this older Angular code which works but not in the latest version of Angular 6.

8条回答
  •  春和景丽
    2020-12-14 00:29

    Adding to what was already said.

    if you want to *ngFor an element , and hide \ show elements in it, on hover, like you added in the comments, you should re-think the whole concept.

    a more appropriate way to do it, does not involve angular at all. I would go with pure CSS instead, using its native :hover property.

    something like:

    App.Component.css

    div span.only-show-on-hover {
        visibility: hidden;
    }
    div:hover span.only-show-on-hover  {
        visibility: visible;
    }
    

    App.Component.html

      
    hover me please. you only see me when hovering

    added a demo: https://stackblitz.com/edit/hello-angular-6-hvgx7n?file=src%2Fapp%2Fapp.component.html

提交回复
热议问题