AngularJS没有填充表格
我有以下ASMX WebService
[WebMethod]
[ScriptMethod(ResponseFormat = ResponseFormat.Json)]
public string GetReport()
{
List<object> result = new List<object>();
DataTable results = conn.GetdatasetByQuery("SELECT * FROM TABLE")
foreach (DataRow i in results.Rows)
{
result.Add(new { A = i["ColumnA"],B = i["ColumnB"] });
}
var res = JsonConvert.SerializeObject(result);
return res;
}
当我通过ajax调用执行此代码或我的Angular函数(如下)返回以下内容:
<?xml version="1.0" encoding="utf-8"?>
<string xmlns="http://tempuri.org/">[{"A":"12","B":"xd"},{"A":"43",{"A":"Abc",{"A":"SW1",{"A":"Abc1","B":"xd"}]</string>
我的HTML /角度如下:
<div class="container" ng-app="myApp" ng-controller="myController">
<div class="panel panel-default">
<div class="panel-heading">
<h4>OEE - Dashboard</h4>
</div>
<div class="panel-body">
<div class="row">
<div class="col-md-12 col-xs-12 form-group">
<table id="Table" class="table table-bordered table-condensed">
<thead>
<tr>
<th>Column A</th>
</tr>
</thead>
<tbody id="TableBody">
<tr ng-repeat="oee in list track by $index">
<td>{{oee.A}}</td>
</tr>
</tbody>
</table>
</div>
</div>
</div>
</div>
</div>
var app = angular.module('myApp',[]);
app.controller('myController',function ($scope,$http) {
var request = {
method: 'POST',url: 'MyAPI.asmx/GetReport',contentType: 'application/json',dataType: 'json'
};
$scope.arrOEE = new Array;
$http(request)
.success(function (jsonData) {
$scope.arrOEE = jsonData;
$scope.list = $scope.arrOEE;
console.log($scope.list);
})
.error(function () {
});
});
如果我将 ooe.Line更改为oee ,则此代码只会向我添加空白行。
顺便说一句,我需要在ng-repeat上放置 $ index跟踪,因为如果没有此操作,我会收到以下错误消息:
错误:[ngRepeat:dupes]
问题出在哪里,我该如何解决?我使用的是1.5.0。