I am using angular 5 and create a reactive form where implement a multiple add input field. This form has a index value that increment form loop ordering. I am using a model to get data. Every data i am getting and working fine but there was some problem, i cant get input field value that auto increment according to loop. here is my code sample.
<form [formGroup]="myForm" novalidate (ngSubmit)="createSurveys(myForm.value)">
<input type="number" class="form-control" [value]="i" formControlName="index" >
</form>
this.myForm = this._fb.group({
name: ['', [Validators.required,Validators.minLength(5)]],
question_record: this._fb.array([
this.initQuestions()
])
});
initQuestions() {
return this._fb.group({
index: [0]
});
}
result
{
"name": "abcde",
"data": [
{
"title": "sssss",
"index": 0
},
{
"title": "ssss",
"index": 0,
}
]
}
when i console my data all data working find but i cant get index data and it always show default value that i set into the model that is 0.