
This commit updates the docs examples to be compatible with the following Angular-specific tslint rules: - `component-selector` - `directive-selector` - `no-conflicting-lifecycle` - `no-host-metadata-property` - `no-input-rename` - `no-output-native` - `no-output-rename` This is in preparation of updating the docs examples `tslint.json` to match the one generated for new Angular CLI apps in a future commit. PR Close #38143
19 lines
512 B
TypeScript
19 lines
512 B
TypeScript
// tslint:disable: directive-selector
|
|
import { Directive, ElementRef, EventEmitter, Output } from '@angular/core';
|
|
|
|
@Directive({selector: '[myClick]'})
|
|
export class ClickDirective {
|
|
@Output('myClick') clicks = new EventEmitter<string>(); // @Output(alias) propertyName = ...
|
|
|
|
toggle = false;
|
|
|
|
constructor(el: ElementRef) {
|
|
el.nativeElement
|
|
.addEventListener('click', (event: Event) => {
|
|
this.toggle = !this.toggle;
|
|
this.clicks.emit(this.toggle ? 'Click!' : '');
|
|
});
|
|
}
|
|
}
|
|
|