Javascript ngRepeat:在以角度发布数据时重复
我正在将表单提交给php页面上的查询,并返回一个数据表。如果我不提交参数,这将非常有效。但是,如果我尝试将参数添加到post(将在查询中使用),我将收到一个ngRepeat:dups错误 你知道是什么引起的吗?还是比较新的角度Javascript ngRepeat:在以角度发布数据时重复,javascript,php,angularjs,Javascript,Php,Angularjs,我正在将表单提交给php页面上的查询,并返回一个数据表。如果我不提交参数,这将非常有效。但是,如果我尝试将参数添加到post(将在查询中使用),我将收到一个ngRepeat:dups错误 你知道是什么引起的吗?还是比较新的角度 $http.post(url,//应用程序模块 var reportRequest=angular.module('reportRequest',[]); 控制器('reportRequest',函数($scope,$http){ //创建一个空白对象来处理表单数据。
$http.post(url,//应用程序模块
var reportRequest=angular.module('reportRequest',[]);
控制器('reportRequest',函数($scope,$http){
//创建一个空白对象来处理表单数据。
$scope.report={};
//调用提交函数。
$scope.submitForm=function(){
//将数据发布到php文件
$http.post(url{
“selectPerson”:$scope.report.firstname
}).成功(功能(数据){
//将返回的数据存储到范围中
$scope.people=数据;
控制台日志(数据);
});
};
});
名字
{{person.firstname}
追踪者必须始终位于ng重复的末尾
更改此项:
<tr ng-repeat="person in people track by $index | filter:search_query">
报表对象为空,然后尝试在提交时发送报表的属性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);
});
我希望这有助于当您发布数据时?我是指事件。您可以发布更多代码或plunker吗?单击一个按钮就会调用该函数通常当您的循环中有重复数据时会发生此错误。此外,我在使用过滤器前按索引跟踪时遇到问题。尝试一下,确实修复了我的重复错误。我现在得到一个没有显示数据的表..我现在可以记录数据了..关于为什么数据不显示有什么想法吗?请记住,如果我删除post参数,它会工作的
{"selectPerson":$scope.report.firstname}
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);
});