How to use mouseover and mouseout in Angular 6

后端 未结 8 1014
既然无缘
既然无缘 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:43

    CSS solution works without a glitch!

    https://www.w3schools.com/code/tryit.asp?filename=GJ4PCJMVQ4LN https://www.w3schools.com/code/tryit.asp?filename=GJ4PPLCCEBRG

    .col-info:hover>.popoverIcon {
        visibility: visible;
      }
    }
    
    .popoverIcon {
      visibility: hidden;
    }
    <div *ngFor="let i of [1,2,3,4]">
    
      <div class="col-info">
        <span class=" popoverIcon ">Show {{i}}</span>
      </div>
    
    </div>

    0 讨论(0)
  • 2020-12-14 00:45
    To avoid blinking problem use following code
    its not mouseover and mouseout instead of that use mouseenter and mouseleave
    
    
    **app.component.html**
    
        <div (mouseenter)="changeText=true" (mouseleave)="changeText=false">
          <span *ngIf="!changeText">Hide</span>
          <span *ngIf="changeText">Show</span>
        </div>
    
    **app.component.ts**
    
    @Component({
       selector: 'app-main',
       templateUrl: './app.component.html'
    })
    export class AppComponent {
        changeText: boolean;
        constructor() {
           this.changeText = false;
        }
    }
    
    0 讨论(0)
提交回复
热议问题