1// just use it normal
2@Output() itch:EventEmitter<any> = new EventEmitter();
3
4//and call in html
5<div appCollar (itch)='scratch()' >
1//generate Angular Directives
2ng generate directive highlight
3
4//it will generate the following component
5import { Directive, ElementRef } from '@angular/core';
6
7@Directive({
8 selector: '[appHighlight]'
9})
10export class HighlightDirective {
11 constructor(el: ElementRef) {
12 el.nativeElement.style.backgroundColor = 'yellow';
13 }
14}
15// you can use the directive in the template as:
16<p appHighlight> highlighted text </p>
1
2 content_copy
3
4 <!-- toggle the "special" class on/off with a property -->
5<div [ngClass]="isSpecial ? 'special' : ''">This div is special</div>
6