Last active
August 21, 2020 02:10
-
-
Save romanejaquez/e08ad133f2769f03d3650b6dee3a0781 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import { Component, OnInit, ViewEncapsulation } from '@angular/core'; | |
import { StepModel } from '../../models/step.model'; | |
import { Observable } from 'rxjs'; | |
import { StepsService } from '../../services/steps.service'; | |
import { Router } from '@angular/router'; | |
@Component({ | |
selector: 'app-form-page', | |
templateUrl: './form-page.component.html', | |
styleUrls: ['./form-page.component.scss'], | |
encapsulation: ViewEncapsulation.None | |
}) | |
export class FormPageComponent implements OnInit { | |
currentStep: Observable<StepModel>; | |
constructor( | |
private stepsService: StepsService, | |
private router: Router) { } | |
ngOnInit(): void { | |
this.currentStep = this.stepsService.getCurrentStep(); | |
} | |
onNextStep() { | |
if (!this.stepsService.isLastStep()) { | |
this.stepsService.moveToNextStep(); | |
} else { | |
this.onSubmit(); | |
} | |
} | |
showButtonLabel() { | |
return !this.stepsService.isLastStep() ? 'Continue' : 'Finish'; | |
} | |
onSubmit(): void { | |
this.router.navigate(['/complete']); | |
} | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment