Search
 
SCRIPT & CODE EXAMPLE
 

JAVASCRIPT

angular HostListener

//import {ElementRef, HostListener } from '@angular/core';

@HostListener('mouseenter') onMouseEnter() {
  this.highlight('yellow');
}

@HostListener('mouseleave') onMouseLeave() {
  this.highlight('');
}

private highlight(color: string) {
  this.el.nativeElement.style.backgroundColor = color;
}
Comment

angular hostlistener

content_copy
@Directive({selector: 'button[counting]'})
class CountClicks {
  numberOfClicks = 0;

  @HostListener('click', ['$event.target'])
  onClick(btn) {
    console.log('button', btn, 'number of clicks:', this.numberOfClicks++);
  }
}

@Component({
  selector: 'app',
  template: '<button counting>Increment</button>',
})
class App {}
Comment

import hostlistener angular

import { HostListener } from '@angular/core'
Comment

PREVIOUS NEXT
Code Example
Javascript :: get specific parent element jquery 
Javascript :: hello world in html using javascript 
Javascript :: javascript remove element from object 
Javascript :: fetch method in javascript 
Javascript :: Select all elements with the same tag 
Javascript :: react-active link 
Javascript :: javascript classes and how to import them 
Javascript :: how to delete an element of an array in javascript 
Javascript :: javascript get nested element 
Javascript :: Web History API 
Javascript :: generate random color 
Javascript :: countdown timer with moment js 
Javascript :: custom react native product rating 
Javascript :: disable button js 
Javascript :: get url query in react 
Javascript :: Handle click outside a component in react with hooks 
Javascript :: how to make a confirm popup in vue 
Javascript :: how to validate phone number regex javascript 
Javascript :: using html forms to define javascript variables 
Javascript :: date javascript format 
Javascript :: looping through an array javascript sum 
Javascript :: insert element in specific index javascript 
Javascript :: window widht jquery 
Javascript :: javascript arrow function 
Javascript :: onsubmit in reactjs 
Javascript :: string interpolation in javascript 
Javascript :: even or odd in javascript 
Javascript :: express send code 
Javascript :: npm sendgrid 
Javascript :: close alert after 5 seconds javascript 
ADD CONTENT
Topic
Content
Source link
Name
8+9 =