我如何使用表行id作为angularjs函数的参数

时间:2015-02-08 09:37:28

标签: javascript angularjs

如何获取data-id属性的值并将其作为showData()函数的参数传递?



<tr ng-repeat="schedule in schedules" ng-model="schedID" data-id="{{schedules.indexOf(schedule)}}">
  <td>MON-THU</td>
  <td>ACTIVITY CENTER</td>
  <td>National Service Training Program 2 (MERGED)</td>
  <td>0</td>
  <td>
    <input type="button" ng-click="showData()">
  </td>
</tr>
&#13;
&#13;
&#13;

1 个答案:

答案 0 :(得分:0)

使用$ index代替:

<tr ng-repeat="schedule in schedules" ng-model="schedID" data-id="{{schedules.indexOf(schedule)}}">
  <td>MON-THU</td>
  <td>ACTIVITY CENTER</td>
  <td>National Service Training Program 2 (MERGED)</td>
  <td>0</td>
  <td>
    <input type="button" ng-click="showData(schedules.indexOf(schedule))">
  </td>
</tr>