Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/22.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Javascript 如何使用表行id作为angularjs函数的参数_Javascript_Angularjs - Fatal编程技术网

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

Javascript 如何使用表行id作为angularjs函数的参数,javascript,angularjs,Javascript,Angularjs,如何获取数据id属性的值并将其作为showData()函数的参数传递 周一至周四 活动中心 国民服役培训计划2(合并) 0 改用$index: <tr ng-repeat="schedule in schedules" ng-model="schedID" data-id="{{schedules.indexOf(schedule)}}"> <td>MON-THU</td> <td>ACTIVITY CENTER</td>

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


周一至周四
活动中心
国民服役培训计划2(合并)
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>

周一至周四
活动中心
国民服役培训计划2(合并)
0

您能显示控制器代码吗?我尝试了您的解决方案,但在筛选表的内容时,$index的值发生了变化。使用索引的值保持不变,但我的问题是如何将其作为参数传递给showData()函数。当数据更改时,索引将始终更改。为什么不直接传递对象本身呢?您使用了对象吗?为什么我的答案突然被接受了?我使用这个“showData(schedules.indexOf(schedule))”来传递schedule索引作为showData的参数。谢谢你的回答。