2016-12-05 53 views
0

我要上點擊定位標籤的訪問當前行項目ID值在點擊的錨標記獲取當前行值

$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>

回答

3

您可以在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> 

控制器

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

爲我工作! –