ngModel绑定在角度6的嵌套ngFor中不起作用

时间:2018-08-01 13:17:07

标签: angular6

在与一种疾病相对应的一个下拉列表中选择值正在更改列表中其他疾病的所有疫苗接种值和日期。 NgModel值绑定在角度6中的嵌套Json对象的动态行生成中不起作用。

Json格式:

{"diseaseList":
[{"diseaseVaccin":"Polio",
"doseList":
[{"value":"Vaccination1","doseDate":"26-Jan-2016 ","vaccineCompany":"abc"},
{"value":"Vaccination2","doseDate":" 15-Aug-2016","vaccineCompany":"xyz"},
{"value":"Vaccination3","doseDate":" 26-Jan-2017","vaccineCompany":"mnc"}
]},
{"diseaseVaccin":"Maleria",
"doseList":
[{"value":"Vaccination1","doseDate":"12-dec-2016 ","vaccineCompany":"kyz"},
{"value":"Vaccination2","doseDate":"18-dec-2016 ","vaccineCompany":"lmn"}]
}]
}

HTML代码:

<div *ngFor="let diseaseVaccin of child.diseaseList;let i = index " >      


    <tr class="form-style-1"


      <td >{{i+1}}</td>
      <td >{{diseaseVaccin.name}}</td>

    </tr>

    <tr class="form-style-1"  *ngFor="let dose of diseaseVaccin.doseList ;let j = index ">
        <td><label id="spaM4">{{dose.value}}</label></td>
        <td><input type="date" name="doseDate{{j}}" required  [(ngModel)]="dose.doseDate" ></td>
        <td><select class="form-control" name="vaccineCompany{{j}}"   required  [(ngModel)]="dose.vaccineCompany">
            <option >
              xyz product lists
            </option>
        </select>
        </td>
    </tr>
</div> 

0 个答案:

没有答案