I have a drop-down menu and a form with dynamic textbox.
This is my dropdown menu, which on change I store them to firstYear and secondYear
<select class="form-control" id="year" name="year" [(ngModel)]="yearRange" (change)="onFilter($event)">
<option value='2018-2019'>2018-2019</option>
<option value='2017-2018'>2017-2018</option>
<option value='2016-2017'>2016-2017</option>
</select>
public updateForm: NgForm;
public value_01: any; public value_02: any; public value_03: any;
onFilter(data: any) {
....
yearSplit = this.yearRange.split("-");
this.firstYear = yearSplit[0];
this.secondYear = yearSplit[1];
}
I want to post the form with key as countryname_year_1 for lets say country selected is "India", year is "2018" and month is january. I have tried following code. I am working here:
stackblitz.com/edit/angular-mcnxrq
<form name="updateForm" #updateForm="ngForm" (ngSubmit)="submit(updateForm.value)" *ngIf="showEdit" >
<div class="forex">
<table class="table table-bordered">
<tr>
<td>{{firstYear}}</td>
<td><input type="number" step="any" class="form-control" id="{{labelCountry}}_{{firstYear}}_01" name="{{labelCountry}}_{{firstYear}}_01" [(ngModel)]="value_01"></td>
<td><input type="number" step="any" class="form-control" id="{{labelCountry}}_{{firstYear}}_02" name="{{labelCountry}}_{{firstYear}}_02" [(ngModel)]="value_02"></td>
I am not sure how to fix this issue.
Can anybody please help me?
Thank You.