Warning: file_get_contents(/data/phpspider/zhask/data//catemap/1/angularjs/25.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 如何在Angularjs中使用复选框函数访问表数据_Javascript_Angularjs_Angularjs Ng Repeat - Fatal编程技术网

Javascript 如何在Angularjs中使用复选框函数访问表数据

Javascript 如何在Angularjs中使用复选框函数访问表数据,javascript,angularjs,angularjs-ng-repeat,Javascript,Angularjs,Angularjs Ng Repeat,我在Angularjs中有一个表,每行有一个复选框。单击复选框时,我希望启动一个警报功能,以显示所单击行的内容。我面临的问题是警报函数如何访问行的数据内容 html中的表格如下所示 <table class="table table-hover data-table sort display"> <thead> <tr> <th>Name</th> <th>Location</th>

我在
Angularjs
中有一个表,每行有一个
复选框。单击
复选框
时,我希望启动一个警报功能,以显示所单击行的内容。我面临的问题是警报函数如何访问行的数据内容

html
中的表格如下所示

<table class="table table-hover data-table sort display">
<thead>
  <tr>
    <th>Name</th>
    <th>Location</th>   
    <th>Checkbox Alert</th>
  </tr>
</thead>
<tbody>
  <tr ng-repeat="item in filteredList | orderBy:columnToOrder:reverse">  
    <td>{{item.name}}</td>
    <td>{{item.location}}</td>  
    <td> <input type="checkbox" ng-click="alert_display()"> </td>
  </tr>
</tbody>
</table>
$scope.alert_display = function()
{
    alert("Testing");
};
我希望
alert\u display()
显示相关行的
{{item.name}
{{item.location}
的内容。

执行以下操作:

<input type="checkbox" ng-model="selected" ng-change="display(selected, item)">

这是小提琴:

谢谢。它部分起作用。投了赞成票,但这并不是我想要的答案。出于某种原因,我必须选中,然后取消选中复选框才能启动显示功能。我如何让显示功能在每次单击复选框时启动,而不管我是选中还是取消选中它?检查小提琴,现在每当你单击时它都会发出警报|松开你就是男人!这就是我想要的答案!我已把你的答案标为正确答案。谢谢
$scope.display = function(selected, item) {

    if(selected)
         alert(item.name + ' ' + item.location);
    else
         // do sth else

}