angular directive

JavaScript
// just use it normal
@Output() itch:EventEmitter<any> = new EventEmitter();

//and call in html
<div appCollar (itch)='scratch()' >//generate Angular Directives
ng generate directive highlight

//it will generate the following component
import { Directive, ElementRef } from '@angular/core';

@Directive({
  selector: '[appHighlight]'
})
export class HighlightDirective {
    constructor(el: ElementRef) {
       el.nativeElement.style.backgroundColor = 'yellow';
    }
}
// you can use the directive in the template as:
<p appHighlight> highlighted text </p>import { Directive, ElementRef } from '@angular/core';<p [ngStyle]="{`THE CSS YOPU WANT TO ADD`}"> I am an Attribute Directive</p>      
        content_copy
      
      ng generate directive highlight
    
Source

Also in JavaScript: