From cfb41452ce84e734546b50d495ee320a223912ce Mon Sep 17 00:00:00 2001 From: krzysztof-grzybek Date: Wed, 10 Oct 2018 18:42:07 +0200 Subject: [PATCH] docs: update testing doc example style for HostListener (#26372) HostListener is preferred over host metadata by official style guide PR Close #26372 --- .../testing/src/testing/router-link-directive-stub.ts | 6 +++--- aio/content/guide/testing.md | 2 +- 2 files changed, 4 insertions(+), 4 deletions(-) diff --git a/aio/content/examples/testing/src/testing/router-link-directive-stub.ts b/aio/content/examples/testing/src/testing/router-link-directive-stub.ts index 761529d726..4da6f8fd04 100644 --- a/aio/content/examples/testing/src/testing/router-link-directive-stub.ts +++ b/aio/content/examples/testing/src/testing/router-link-directive-stub.ts @@ -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; } diff --git a/aio/content/guide/testing.md b/aio/content/guide/testing.md index 7bb81bc831..da40b12dd2 100644 --- a/aio/content/guide/testing.md +++ b/aio/content/guide/testing.md @@ -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 `` anchor elements in `AppComponent`) to the stub directive's `onClick` method. Clicking the anchor should trigger the `onClick()` method,