如何在角度6中传递动态formArray的索引

时间:2019-06-10 09:23:23

标签: angular

form.html

pattern('^([0-9]+)(.[0-9]+)?\s?([^iIbB])?([iI])?([bB])?$')
    ->match($size)
    ->first(function (Match $match) {

        // whether the group was used in a pattern
        $match->hasGroup(14);   

        // whether the group was matched, even if last or empty string
        $match->matched(5);

        // group, or default value if not matched
        $match->group(5)->orReturn('unmatched');     
    });

form.ts

 <tbody>
            <tr formArrayName="resultStored" *ngFor="let data of resultStored;let i = index">
            <td>{{data?.tbl_medicine?.name}}</td>
            <td>{{data?.duration}} {{data?.tbl_duration?.durationType}}</td>
           <td [formGroupName]="i">
                <div class="row supplayRow">
                <div class="col-md-2">
                  <label class="chkBox">
                    <input type="checkbox"  (change)="UpdateSupply(data.id,$event,data)" formControlName="is_partial_id">
                    <span class="checkmark"></span>
                  </label>
                </div>
                <div class="col-md-4">

                  <input type="text" class="chkInput"   placeholder="xxx" formControlName="durationSupplyID_id">

                </div>
                <div class="col-md-6">
                  <select class="form-control" type="text" name="duration"  formControlName="durationSupplyTypeId_id">
                    <option *ngFor="let durationData of durationValueList" value="{{durationData?.id}}">
                      {{durationData?.durationType}}</option>
                  </select>
                </div>
              </div>
            </td>
          </tr>  
         </tbody>

这里有一行是动态创建的,但我无法在组件内部获取特定的行值。我认为M以错误的方式传递索引。请帮助我怎么做id?谢谢

0 个答案:

没有答案