2015-12-05 126 views
1

我試圖獲取ID並通過角JS傳遞函數,但我沒有在函數中獲得ID。將角色ID傳遞給函數JS

這裏是代碼

<tr ng-repeat="record in records | filter:filters.search| filter: filters.searchdd | filter:customFilter(unit)"> 
       <td>{{ record.name }}</td> 
       <td>{{appctrl.currentOrgType.name}}</td> 
       <td> {{record.id}}</td> 
       <td> 
        <div class="dropdown"> 
         <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> 
          select option 
         <span class="caret"></span> 
         </button> 
         <ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> 
         <li><a href="#" ng-click="locateOnMap(record.id)">Locate on Map</a></li> 
         <li><a href="#">Edit Coordinates</a></li> 

這裏我打電話警告標識。但我得到什麼

$scope.locateOnMap=function(id) 
    { 
     alert('Get ID ' + id); 

    } 
+0

嘗試'ngClick'表達連接到'LI'元素代替'A'元素 –

+0

這是否顯示正確的ID:'​​{{record.id}}'? –

回答

1

我會測試與console.log

$scope.locateOnMap=function(record) 
    { 
     console.log('record',record); 
    } 

,並通過全程記錄,以確保ID存在

<tr ng-repeat="record in records | filter:filters.search| filter: filters.searchdd | filter:customFilter(unit)"> 
       <td>{{ record.name }}</td> 
       <td>{{appctrl.currentOrgType.name}}</td> 
       <td> {{record.id}}</td> 
       <td> 
        <div class="dropdown"> 
         <button class="btn btn-default dropdown-toggle" type="button" id="dropdownMenu1" data-toggle="dropdown" aria-haspopup="true" aria-expanded="true"> 
          select option 
         <span class="caret"></span> 
         </button> 
         <ul class="dropdown-menu" aria-labelledby="dropdownMenu1"> 
         <li><a href="#" ng-click="locateOnMap(record)">Locate on Map</a></li> 
         <li><a href="#">Edit Coordinates</a></li>