【发布时间】:2015-02-27 08:56:55
【问题描述】:
我有一个带有表格的输入文本,在该表格中我从带有 ng-repeat 的 JSON 中过滤了一些值,同时我正在输入。
<input type="text" placeholder="Choose" ng-model="item.sTxt"/>
<table>
<thead>
<tr>
<th>First Value</th>
<th>Second Value</th>
</tr>
</thead>
<tbody>
<tr
data-ng-repeat="item in numberList.getList | filter:searchText"
ng-click="setSelected(item.last)">
<td>{{item.first}}</td>
<td>{{item.last}}</td>
</tr>
</tbody>
</table>
我可以通过这种方式在表格中单击一行时显示警报:
$scope.idSelectedVote = null;
$scope.setSelected = function (idSelectedVote) {
$scope.idSelectedVote = idSelectedVote;
alert(idSelectedVote);
};
但我会采用该值并将其传递到我的输入文本中。我怎么能在 angularjs 中做到这一点?
【问题讨论】:
标签: javascript angularjs input html-table