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:
parent
f1fb62d1e5
commit
cfb41452ce
|
@ -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;
|
||||
}
|
||||
|
|
|
@ -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,
|
||||
|
|
Loading…
Reference in New Issue