Skip to content

Commit de193db

Browse files
committed
Finished
1 parent 8ccac07 commit de193db

File tree

2 files changed

+22
-2
lines changed

2 files changed

+22
-2
lines changed

src/step.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -47,6 +47,7 @@ export class StepComponent implements OnInit {
4747
@Input() activeStep?: boolean = false;
4848
@Input() firstStep?: boolean = false;
4949
@Input() lastStep?: boolean = false;
50+
@Input() shouldEnter?: boolean = true;
5051
constructor() { }
5152
@Output() onBack = new EventEmitter<this>();
5253

src/wizard.ts

Lines changed: 21 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
import { Component, ContentChildren, QueryList, AfterContentInit, Input, Output} from '@angular/core';
1+
import { Component, ContentChildren, QueryList, AfterContentInit,EventEmitter, Input, Output} from '@angular/core';
22
import { StepComponent } from './step';
33

44

@@ -81,13 +81,30 @@ export class WizardComponent implements AfterContentInit{
8181
navWidth: number;
8282
@Input() color: string = 'blue';
8383
@ContentChildren(StepComponent) steps: QueryList<StepComponent>;
84-
84+
@Output() onFinish = new EventEmitter<this>();
8585
navClicked(id: number) {
8686
this.items[this.currentStepIndex].step.activeStep = false;
8787
this.currentStepIndex = id;
8888
this.currentStep = this.items[id];
8989
this.items[this.currentStepIndex].step.activeStep = true;
9090
console.log(this.currentStep);
91+
}
92+
goto(id: number) {
93+
if ( id >= this.items.length){
94+
this.onFinish.emit(this.items);
95+
}
96+
else if(id < 0)
97+
{
98+
this.goto(0)
99+
}
100+
else{
101+
this.items[this.currentStepIndex].step.activeStep = false;
102+
this.currentStepIndex = id;
103+
this.currentStep = this.items[id];
104+
this.items[this.currentStepIndex].step.activeStep = true;
105+
console.log(this.currentStep);
106+
}
107+
91108
}
92109
ngAfterContentInit() {
93110
let i = 0;
@@ -108,10 +125,12 @@ export class WizardComponent implements AfterContentInit{
108125
this.items[this.currentStepIndex].step.activeStep = true;
109126
console.log(this.currentStep);
110127
}
128+
111129
});
112130
r.onNext.subscribe((title : StepComponent) => {
113131
if(this.currentStepIndex == this.items.length - 1){
114132
//TODO call on finish
133+
this.onFinish.emit(this.items);
115134
console.log("Finished");
116135
}
117136
else{

0 commit comments

Comments
 (0)