If you want to perform a hover like event on any HTML element, then you can do it like this.
HTML
<div (mouseenter) ="mouseEnter('div a') " (mouseleave) ="mouseLeave('div A')"> <h2>Div A</h2> </div> <div (mouseenter) ="mouseEnter('div b')" (mouseleave) ="mouseLeave('div B')"> <h2>Div B</h2> </div>
Component
import { Component } from '@angular/core'; @Component({ moduleId: module.id, selector: 'basic-detail', templateUrl: 'basic.component.html', }) export class BasicComponent{ mouseEnter(div : string){ console.log("mouse enter : " + div); } mouseLeave(div : string){ console.log('mouse leave :' + div); } }
You should use both mouseenter
and mouseleave
events in order to fully implement functional hover events in angular 2.
Related Posts:
- Angular: conditional class with *ngClass
- Can’t bind to ‘ngModel’ since it isn’t a known property of ‘input’
- What is an unhandled promise rejection?
- What’s the difference between event.stopPropagation and event.preventDefault?
- Angular: mat-form-field must contain a MatFormFieldControl
- (change) vs (ngModelChange) in angular
- Cannot find module ‘@angular-devkit/core’
- No value accessor for form control
- Angular: Error no directive with “exportAs” set to “ngForm”
- Angular ForEach in Angular4/Typescript?
- What does on() in JavaScript do?
- Angular 4 setting selected option in Dropdown
- Angular4 – No value accessor for form control
- Angular: conditional class with *ngClass
- Angular: conditional class with *ngClass
- npm WARN … requires a peer of … but none is installed. You must install peer dependencies yourself
- What is ViewChild in Angular2?
- Module not found: Error: Can’t resolve ‘fs’ in
- Javascript removeEventListener not working
- Angular 2 – Using ‘this’ inside setTimeout
- How to fix Cannot find module ‘typescript’ in Angular 4?
- How to set Angular 4 background image?
- SyntaxError: Unexpected token C in JSON at position 0 – Ionic 2 Http GET request
- Crop the image using JavaScript
- Angular 4 setTimeout() with variable delay and wait
- What does the .subscribe() function do?
- How do I download a file with Angular2 or greater
- Fire oninput event with jQuery
- What are differences between SystemJS and Webpack?
- How to use forEach loop correctly in angular 2?
- Angular 2 Sort table columns
- How to use onBlur event on Angular2?
- How do I install Angular 2 using NPM?
- Why onbeforeunload event is not firing
- Using Angular 2 without TypeScript Transpiler
- What is the Javascript event for an item being added to the cart in Woocommerce?
- List of JS Events for Widgets?
- iFrame onLoad in custom Gutenberg block
- addEventListener vs onclick
- How do I check if an array includes a value in JavaScript?
- JavaScript document.getElementById().value logs empty value
- What is console.log?
- Copy array by value
- Compare two dates with JavaScript
- In reactJS, how to copy text to clipboard?
- SyntaxError: Adjacent JSX elements must be wrapped in an enclosing tag
- Uncaught SyntaxError: Invalid or unexpected token
- JavaScript TypeError: Cannot read property ‘style’ of null
- Make javascript alert Yes/No Instead of Ok/Cancel
- How to create a dialog with “yes” and “no” options
- Adding images to a Bootstrap Carousel with AJAX
- XMLHttpRequest cannot load XXX No ‘Access-Control-Allow-Origin’ header
- Uncaught TypeError: Cannot read property ‘props’ of null
- ES6: Create Strings using Template Literals – Freecodecamp
- Youtube api – stop video
- Uncaught TypeError: Cannot read property ‘msie’ of undefined – jQuery tools
- Angular JS Uncaught Error: [$injector:modulerr]
- How do I convert an integer to binary in JavaScript?
- What does window.jQuery and window.$ mean?
- How to change date format in JavaScript
- OnChange event handler for radio button (INPUT type=”radio”) doesn’t work as one value
- React-Router : What is the purpose of IndexRoute?
- How to implement “select all” check box in HTML?
- JQuery get the title of a button
- How to open a URL using PHP?
- Trying to load jquery into tampermonkey script
- Atom JavaScript Autocomplete
- How to format a UTC date as a `YYYY-MM-DD hh:mm:ss` string using NodeJS?
- JavaScript button onclick not working
- Invariant Violation: _registerComponent(…): Target container is not a DOM element
- How to count string occurrence in string?
- Ajax success function
- What is the equivalent of Java’s System.out.println() in Javascript?
- How can I exit from a javascript function? [duplicate]
- Object doesn’t support property or method ‘addEventListener’
- How to fix javascript .toFixed is not a Function error
- Implementing Isomorphic JavaScript (React JS) in WordPress?
- Any advantage of using wp_scripts and is_IE when enqueuing scripts
- TinyMCE in a div / textarea on frontend?
- WordPress problem with htmlentities
- VB.net and WordPress
- Gutenberg passing block attributes to component in ES6/ESNext
- How to add a custom.js file for a child-theme in a swift way?
- WP REST API Post Status Using JavaScript
- var is undefined in a Gutenberg block
- Custom wp.editor.initialize settings ignored
- Why my javascript code not working for the dashboard of wordpress admin?
- Got a TypeError after update and need to adapt found solution
- How do you filter the list of states when country is selected? [closed]
- Prevent update_checkout from firing mid-typing
- How to move core js files into the footer
- Suddenly extra hex string in tags
- Including Styles and JS files to work ON my plugin interface
- Gutenberg – useEffect manipulate DOM after block re-renders DOM
- Drodown list return issue
- Spans in gutenberg
- Get a default customizeAction text for a section using Customizer JS API
- custom page url slug needs illegal ?id=1 for javascript
- Use one javascript variable into another javascript file
- How to load JavaScript modules with script_loader_tag hook?