2017-05-26 53 views
0

我正在向php頁面上的查詢提交表單並返回一個數據表。如果我不提交參數,這很好。但是,如果我嘗試向帖子添加參數(在查詢中使用),我收到一個ngRepeat:Dupes錯誤。ngRepeat:使用角度發佈數據時的錯誤

任何想法可能會導致這種情況?還是比較新的角度

$http.post(url ,// Application module 
 
var reportRequest = angular.module('reportRequest',[]); 
 

 
reportRequest.controller('reportRequest', function($scope, $http) { 
 

 
    // create a blank object to handle form data. 
 
    $scope.report = {}; 
 

 
    // calling our submit function. 
 
    $scope.submitForm = function() { 
 
     // Posting data to php file  
 
     $http.post(url, { 
 
      "selectPerson" : $scope.report.firstname 
 
     }).success(function(data){ 
 
      // Stored the returned data into scope 
 
      $scope.people= data; 
 
      console.log(data); 
 
     }); 
 
    }; 
 
});
<table class="table table-hover"> 
 
<tr> 
 
<th>First Name</th> 
 
<th></th> 
 
<th></th> 
 
</tr> 
 
<tr ng-repeat="person in people track by $index | filter:search_query"> 
 
<td><span>{{person.firstname}}</span></td> 
 
</tr> 
 
</table>

+0

當您發佈的數據?我的意思是這個事件。 –

+1

你可以發佈更多的代碼或plunker。 – SaiUnique

+0

正在調用該功能點擊按鈕 – dallas

回答

0

軌道由有你的NG-重複結束時始終。

更改此:

<tr ng-repeat="person in people track by $index | filter:search_query"> 

要這樣:

<tr ng-repeat="person in people | filter:search_query track by $index"> 

然後有關數據未顯示在發送POST數據,這似乎是錯的,即使這部分代碼丟失,並會如果你能告訴我們發生了什麼事情,那就很好:

{"selectPerson":$scope.report.firstname} 

報告對象是空的,然後你嘗試發送提交報告的財產firstname。 但是你確定這個屬性實際上以這種方式存在嗎?而不是像$scope.report.person.firstname? 也許您可以在POST請求之前添加一個console.log(),以查看實際報表對象的外觀。

console.log($scope.report); 
$http.post(url ,{"selectPerson":$scope.report.firstname}).success(function(data){ 
      // Stored the returned data into scope 
      $scope.people= data; 
     console.log(data); 
     }); 

我希望這有助於