Angular 2 Hover event

前端 未结 9 1161
深忆病人
深忆病人 2020-12-02 06:20

In the new Angular2 framework, does anyone know the proper way to do a hover like an event?

In Angular1 there was ng-Mouseov

9条回答
  •  鱼传尺愫
    2020-12-02 06:46

    Simply do (mouseenter) attribute in Angular2+...

    In your HTML do:

    Hover!

    and in your component do:

    import { Component, OnInit } from '@angular/core';
    
    @Component({
      selector: 'component',
      templateUrl: './component.html',
      styleUrls: ['./component.scss']
    })
    
    export class MyComponent implements OnInit {
    
      mouseHover(e) {
        console.log('hovered', e);
      }
    } 
    

提交回复
热议问题