ng-repeat-start仅在数组的ng-change内给出索引'0'

时间:2018-02-06 13:23:10

标签: javascript html angularjs

这里我试图在 ng-change =“info.onRampFeeApplicableChanged(businessJet)”中传递businessJet对象,以便在ng-repeat-start中切换按钮。但即使您更改其他索引值的切换按钮,它也总是给出第一个索引的对象。哪个适用于第一个td元素中“ng-click =”info.onToggleAircarftMoreDetails(businessJet)“

我做错了吗?我想不出来。

<div ng-repeat="aircraftType in info.fboRampFee">

    <table>
       <tbody>
          <tr class="row" ng-repeat-start="businessJet in aircraftType.businessJets track by $index">
             <td ng-click="info.onToggleAircarftMoreDetails(businessJet)"></td>
             <td>
             <span class="onoffswitch">
                 <input type="checkbox" name="businessJet-switch-{{$parent.$index}}" 
                      class="onoffswitch-checkbox" id="businessJet-switch-{{$parent.$index}}" 
                      ng-model="businessJet.IsApplicable"
                   ng-change="info.onRampFeeApplicableChanged(businessJet)">
                     <label class="onoffswitch-label" for="businessJet-switch-{{$parent.$index}}">
                          <span class="onoffswitch-inner"
                                data-swchon-text="YES"
                                  data-swchoff-text="NO"></span>
                                    <span class="onoffswitch-switch"></span>
                     </label>
             </span>
           </td>
          </tr>

         <tr ng-repeat-end>
            <td></td>
         </tr>
       </tbody
    </table>

</div>

2 个答案:

答案 0 :(得分:0)

  

只需删除ng-repeat-start并输入ng-repeat   并从tr标签中删除ng-repeat-end。可能会工作正常

答案 1 :(得分:0)

应该只有 id =“businessJet-switch - {$ index}}”而不是“id =”businessJet-switch - {{$ parent。$ index}}“ 因为我必须获取子数组的索引。它有效。