1- import { Component , ContentChildren , QueryList , AfterContentInit , Input , Output } from '@angular/core' ;
1+ import { Component , ContentChildren , QueryList , AfterContentInit , EventEmitter , Input , Output } from '@angular/core' ;
22import { 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