From 09f5d360434cbf89f365cba13a393f31ba621dcf Mon Sep 17 00:00:00 2001 From: maiyaporn Date: Sat, 17 Jun 2017 21:38:29 -0500 Subject: [PATCH] Add public accessor and Clean up --- src/wizard-step.component.ts | 10 ++++------ src/wizard.component.ts | 17 +++++++---------- 2 files changed, 11 insertions(+), 16 deletions(-) diff --git a/src/wizard-step.component.ts b/src/wizard-step.component.ts index 11dab664..1c457dc3 100644 --- a/src/wizard-step.component.ts +++ b/src/wizard-step.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; +import { Component, Input, Output, EventEmitter } from '@angular/core'; @Component({ selector: 'wizard-step', @@ -9,7 +9,7 @@ import { Component, OnInit, Input, Output, EventEmitter } from '@angular/core'; ` }) -export class WizardStepComponent implements OnInit { +export class WizardStepComponent { @Input() title: string; @Input() hidden: boolean = false; @Input() isValid: boolean = true; @@ -25,10 +25,8 @@ export class WizardStepComponent implements OnInit { constructor() { } - ngOnInit() { - } - - @Input('isActive') set isActive(isActive: boolean) { + @Input('isActive') + set isActive(isActive: boolean) { this._isActive = isActive; this.isDisabled = false; } diff --git a/src/wizard.component.ts b/src/wizard.component.ts index 8c066697..8953f89a 100644 --- a/src/wizard.component.ts +++ b/src/wizard.component.ts @@ -1,4 +1,4 @@ -import { Component, OnInit, Output, EventEmitter, ContentChildren, QueryList, AfterContentInit } from '@angular/core'; +import { Component, Output, EventEmitter, ContentChildren, QueryList, AfterContentInit } from '@angular/core'; import { WizardStepComponent } from './wizard-step.component'; @Component({ @@ -34,7 +34,7 @@ import { WizardStepComponent } from './wizard-step.component'; '.completed { cursor: default; }' ] }) -export class WizardComponent implements OnInit, AfterContentInit { +export class WizardComponent implements AfterContentInit { @ContentChildren(WizardStepComponent) wizardSteps: QueryList; @@ -46,9 +46,6 @@ export class WizardComponent implements OnInit, AfterContentInit { constructor() { } - ngOnInit() { - } - ngAfterContentInit() { this.wizardSteps.forEach(step => this._steps.push(step)); this.steps[0].isActive = true; @@ -74,7 +71,7 @@ export class WizardComponent implements OnInit, AfterContentInit { } } - private get activeStepIndex(): number { + public get activeStepIndex(): number { return this.steps.indexOf(this.activeStep); } @@ -86,13 +83,13 @@ export class WizardComponent implements OnInit, AfterContentInit { return this.activeStepIndex > 0; } - goToStep(step: WizardStepComponent) { + public goToStep(step: WizardStepComponent): void { if (!this.isCompleted) { this.activeStep = step; } } - next() { + public next(): void { if (this.hasNextStep) { let nextStep: WizardStepComponent = this.steps[this.activeStepIndex + 1]; this.activeStep.onNext.emit(); @@ -101,7 +98,7 @@ export class WizardComponent implements OnInit, AfterContentInit { } } - previous() { + public previous(): void { if (this.hasPrevStep) { let prevStep: WizardStepComponent = this.steps[this.activeStepIndex - 1]; this.activeStep.onPrev.emit(); @@ -110,7 +107,7 @@ export class WizardComponent implements OnInit, AfterContentInit { } } - complete() { + public complete(): void { this.activeStep.onComplete.emit(); this._isCompleted = true; }