Angular2:ngFor内部ngb-accordian总是指向最后一个元素

时间:2017-08-01 05:47:59

标签: angular ng-bootstrap angular-bootstrap

我正在开发一个基于ngb-accordion的小部件,它内部包含一个ngb-panel,其中包含一个循环遍历元素数组的div。

数据结构:            1-N
员工< ------> previousEmployments            1-1
员工< ------>保险

员工,保险和以前的员工都在单独的ngb-panel中。包含previousEmployments的ngb面板在div元素上包含ngFor。

<div *ngFor="let previousEmploymenttemp of employee.previousEmployments; let i=index" >
        <div class="col-sm-12">          

    <div class="row">


    <div class="form-group col-md-4">       
    <ig-input  [inputField]="editForm.controls.company" [inputErrors]="editForm.controls.company?.errors">
        <label class="form-control-label" jhiTranslate="finaldemoApp.employee.previousEmployment.company" for="subfield_company">Company</label>

        <input type="text" class="form-control" name="company" id="subField_company"
            [(ngModel)]="previousEmploymenttemp.company"
         />
    </ig-input>

    </div> 
....
....

让我们假设employee.previousEmployments包含三个元素,ngFor循环遍历元素,但所有输入都包含元素employee.previousEmployments [2]的值,即最后一个元素。

0 个答案:

没有答案