javascript - 单击 anchor 标记时获取当前行值

标签 javascript jquery angularjs

我想在单击 anchor 标记时访问当前行 ItemID 值

$scope.Test12 = function() {
  ID = document.getElementById("ItemId"); //Want to access Clicked ItemID Value
}
<tr ng-repeat="customer in customers">

  <td><a ng-href='#here' ng-click='Test12()' onclick="OpenDialog()">{{customer.OldAccount_x002f_Cost_x0020_Elem}}</a>
  </td>

  <td>{{customer.NewAccount_x002f_CostElement}}</td>
  <td>{{customer.Description}}</td>
  <td>
    <input id="ItemId" type="text" name="ID" value={{customer.ID}}>
  </td>
</tr>

最佳答案

您可以在 ngClick 中传递 customer ,然后您可以访问 customer 对象的属性。

<tr ng-repeat="customer in customers">  
    <td><a ng-href='#here' ng-click='Test12(customer)' onclick="OpenDialog()">{{customer.OldAccount_x002f_Cost_x0020_Elem}}</a></td>        
</tr>  

Controller

$scope.Test12 = function(customer){
    ID=customer.ID
}

关于javascript - 单击 anchor 标记时获取当前行值,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/40971461/

相关文章:

javascript - AJAX 成功时无法显示 JSON 结果

javascript - 使用适用于 Box API 的 Javascript SDK

javascript - 使用 jQuery 按内容选择元素

javascript - Angular : Cannot read property 'length' of undefined when using ng-minlength

Angularjs 指令 Canvas 模糊

javascript - 在 Google 表格中添加数组作为 EmbeddedChart 的 "range"

javascript - 将 jQuery Text Complete 与包含键和值的数组一起使用

javascript - 我怎样才能显示一个随机数 - jQuery

javascript - 我可以将带有 GIF 内容的 $.post 函数的结果放入 javascript Image 对象吗?

javascript - ng-model 和 ng-model-instant AngularJS 之间的区别