docs: update testing doc example style for HostListener (#26372)

HostListener is preferred over host metadata by official style guide

PR Close #26372
This commit is contained in:
krzysztof-grzybek 2018-10-10 18:42:07 +02:00 committed by Andrew Kushnir
parent f1fb62d1e5
commit cfb41452ce
2 changed files with 4 additions and 4 deletions

View File

@ -1,4 +1,4 @@
import { Directive, Input } from '@angular/core';
import { Directive, Input, HostListener } from '@angular/core';
// export for convenience.
export { RouterLink} from '@angular/router';
@ -6,13 +6,13 @@ export { RouterLink} from '@angular/router';
/* tslint:disable:directive-class-suffix */
// #docregion router-link
@Directive({
selector: '[routerLink]',
host: { '(click)': 'onClick()' }
selector: '[routerLink]'
})
export class RouterLinkDirectiveStub {
@Input('routerLink') linkParams: any;
navigatedTo: any = null;
@HostListener('click')
onClick() {
this.navigatedTo = this.linkParams;
}

View File

@ -2205,7 +2205,7 @@ seen in the `AppComponent` template.
The URL bound to the `[routerLink]` attribute flows in to the directive's `linkParams` property.
The `host` metadata property wires the click event of the host element
The `HostListener` wires the click event of the host element
(the `<a>` anchor elements in `AppComponent`) to the stub directive's `onClick` method.
Clicking the anchor should trigger the `onClick()` method,