diff --git a/public/docs/_examples/cb-component-communication/ts/app/countdown-timer.component.ts b/public/docs/_examples/cb-component-communication/ts/app/countdown-timer.component.ts index aedbbf5906..0175993303 100644 --- a/public/docs/_examples/cb-component-communication/ts/app/countdown-timer.component.ts +++ b/public/docs/_examples/cb-component-communication/ts/app/countdown-timer.component.ts @@ -1,18 +1,29 @@ // #docregion -import {Component, EventEmitter, OnInit, Output} from 'angular2/core'; +import {Component, OnInit, OnDestroy} from 'angular2/core'; @Component({ selector:'countdown-timer', template: '

{{message}}

' }) -export class CountdownTimerComponent implements OnInit { +export class CountdownTimerComponent implements OnInit, OnDestroy { intervalId = 0; message = ''; seconds = 11; + clearTimer() {clearInterval(this.intervalId);} + + ngOnInit() { this.start(); } + ngOnDestroy() { this.clearTimer(); } + + start() { this._countDown(); } + stop() { + this.clearTimer(); + this.message = `Holding at T-${this.seconds} seconds`; + } + private _countDown() { - clearInterval(this.intervalId); + this.clearTimer(); this.intervalId = setInterval(()=>{ this.seconds -= 1; if (this.seconds == 0) { @@ -23,11 +34,4 @@ export class CountdownTimerComponent implements OnInit { } }, 1000); } - - ngOnInit() { this.start(); } - start() { this._countDown(); } - stop() { - clearInterval(this.intervalId); - this.message = `Holding at T-${this.seconds} seconds`; - } } \ No newline at end of file diff --git a/public/docs/ts/latest/cookbook/_data.json b/public/docs/ts/latest/cookbook/_data.json index eff6f5f019..5ee951914b 100644 --- a/public/docs/ts/latest/cookbook/_data.json +++ b/public/docs/ts/latest/cookbook/_data.json @@ -2,7 +2,7 @@ "_listtype": "alpha", "index": { - "title": "Cookbooks" + "title": "Cookbook" }, "component-communication": {