blob: d46aa480e7918165d865a3cb8791903973c1c01e (
plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
|
import { Component, Input, OnDestroy, OnInit } from '@angular/core';
import * as _ from 'lodash';
import { Observable, Subscription } from 'rxjs';
import { WizardStepModel } from '~/app/shared/models/wizard-steps';
import { WizardStepsService } from '~/app/shared/services/wizard-steps.service';
@Component({
selector: 'cd-wizard',
templateUrl: './wizard.component.html',
styleUrls: ['./wizard.component.scss']
})
export class WizardComponent implements OnInit, OnDestroy {
@Input()
stepsTitle: string[];
steps: Observable<WizardStepModel[]>;
currentStep: WizardStepModel;
currentStepSub: Subscription;
constructor(private stepsService: WizardStepsService) {}
ngOnInit(): void {
this.stepsService.setTotalSteps(this.stepsTitle.length);
this.steps = this.stepsService.getSteps();
this.currentStepSub = this.stepsService.getCurrentStep().subscribe((step: WizardStepModel) => {
this.currentStep = step;
});
}
onStepClick(step: WizardStepModel) {
this.stepsService.setCurrentStep(step);
}
ngOnDestroy(): void {
this.currentStepSub.unsubscribe();
}
}
|