Я сделал это в вашей Реактивной форме. Пожалуйста, проверьте.
Stackblitz Рабочий пример
Компонент
myForm: FormGroup;
currentQuestionIndex = 0;
ngOnInit() {
this.myForm = new FormGroup({
name: new FormControl('Benedict'),
email: new FormControl(''),
message: new FormControl(''),
questions: new FormArray([
new FormControl('This is Q1'),
new FormControl('This is Q2'),
new FormControl('This is Q3')
])
});
}
HTML
<form [formGroup]="myForm" (ngSubmit)="onSubmit(myForm)">
What is your name ? <input formControlName="name" placeholder="Your name"><br>
What is your email? <input formControlName="email" placeholder="Your email"><br>
What is your message? <input formControlName="message" placeholder="Your message"><br>
<p>
Questions: {{ myForm.get('questions').value[currentQuestionIndex] }}
</p>
<button type="button" (click)="currentQuestionIndex = currentQuestionIndex - 1">Previous</button>
<button type="button" (click)="currentQuestionIndex = currentQuestionIndex + 1">Next</button>
</form>