diff --git a/aio/content/examples/lifecycle-hooks/src/app/spy.directive.ts b/aio/content/examples/lifecycle-hooks/src/app/spy.directive.ts index 16f9440073..c364b3deca 100644 --- a/aio/content/examples/lifecycle-hooks/src/app/spy.directive.ts +++ b/aio/content/examples/lifecycle-hooks/src/app/spy.directive.ts @@ -10,15 +10,16 @@ let nextId = 1; // Usage:
...
@Directive({selector: '[appSpy]'}) export class SpyDirective implements OnInit, OnDestroy { + private id = nextId++; constructor(private logger: LoggerService) { } ngOnInit() { - this.logger.log(`Spy #${nextId++} onInit`); + this.logger.log(`Spy #${this.id} onInit`); } ngOnDestroy() { - this.logger.log(`Spy #${nextId++} onDestroy`); + this.logger.log(`Spy #${this.id} onDestroy`); } } // #enddocregion spy-directive