嗨我有一个数组在这个7对象存在和3个反相器,意味着 根据数据正确获取列但列是 错了,在特定日期创建了多少个逆变器 那些人应该来。如果当天的2个inverotrs是2列 应该动态地......我没有得到任何人可以帮助我。
var url = "http://52.9.55.95:91/api/ExcelDetails/ExcelExportForLog?Sid=1&FromDt=2017-02-21&ToDt=2017-02-22"
console.log(url);
var tabledata=[];
$scope.inventorarray=[];
http({
method: 'GET',
dataType: 'json',
contentType: "application/json; charset=utf-8",
url: url
}).
success(function (data, status, headers, config) {
// $scope.loaded = true;
$scope.data = data;
$timeout(function () { $scope.loaded = true; }, 500);
//console.log("reporting to data received : success");
console.log(data);
for(var i=0;i<data.length;i++){
var tdata={
"heading":"InvCount: "+i,
"Date":data[i].TimeofReading.substring(0,10)
}
tabledata.push(tdata);
}
$scope.tablearray=tabledata;
console.log($scope.tablearray)
for(var i=0;i<data.length;i++){
var Lastreadingkey=data[i].Lastreading;
var Readingbykey=data[i].Readingby;
debugger
var tdata={
"Lastreading":Lastreadingkey,
"Readingby":Readingbykey
}
$scope.inventorarray.push(tdata);
}
console.log($scope.inventorarray)
}).
error(function (data, status, headers, config) {
//$scope.loaded = false;
swal({ title: "Warning!", text: "Something went wrong!", type: "warning", confirmButtonText: "OK" });
$timeout(function () { $scope.loaded = true; }, 500);
//console.log("reporting to data received : failure");
//console.log(data);
});
var url = "http://52.9.55.95:91/api/ExcelDetails/ExcelExportForLog?Sid=1&FromDt=2017-02-21&ToDt=2017-02-22"
console.log(url);
var tabledata=[];
$scope.inventorarray=[];
http({
method: 'GET',
dataType: 'json',
contentType: "application/json; charset=utf-8",
url: url
}).
success(function (data, status, headers, config) {
$scope.data = data;
$timeout(function () { $scope.loaded = true; }, 500);
for(var i=0;i<data.length;i++){
var tdata={
"heading":"InvCount: "+i,
"Date":data[i].TimeofReading.substring(0,10)
}
tabledata.push(tdata);
}
$scope.tablearray=tabledata;
console.log($scope.tablearray)
for(var i=0;i<data.length;i++){
var Lastreadingkey=data[i].Lastreading;
var Readingbykey=data[i].Readingby;
debugger
var tdata={
"Lastreading":Lastreadingkey,
"Readingby":Readingbykey
}
$scope.inventorarray.push(tdata);
}
console.log($scope.inventorarray)
}).
error(function (data, status, headers, config) {
//$scope.loaded = false;
swal({ title: "Warning!", text: "Something went wrong!", type: "warning", confirmButtonText: "OK" });
$timeout(function () { $scope.loaded = true; }, 500);
});
$scope.tableToExcel=(function() {
var uri = 'data:application/vnd.ms-excel;base64,'
, template = '<html xmlns:o="urn:schemas-microsoft-com:office:office" xmlns:x="urn:schemas-microsoft-com:office:excel" xmlns="http://www.w3.org/TR/REC-html40"><head><!--[if gte mso 9]><xml><x:ExcelWorkbook><x:ExcelWorksheets><x:ExcelWorksheet><x:Name>{worksheet}</x:Name><x:WorksheetOptions><x:DisplayGridlines/></x:WorksheetOptions></x:ExcelWorksheet></x:ExcelWorksheets></x:ExcelWorkbook></xml><![endif]--></head><body><table>{table}</table></body></html>'
, base64 = function(s) { return window.btoa(unescape(encodeURIComponent(s))) }
, format = function(s, c) { return s.replace(/{(\w+)}/g, function(m, p) { return c[p]; }) }
return function(table, name) {
if (!table.nodeType) table = document.getElementById(table)
var ctx = {worksheet: name || 'Worksheet', table: table.innerHTML}
window.location.href = uri + base64(format(template, ctx))
}
})()
}]);
myhtml页面
<table id="example1" class="table table-bordered table-striped">
<thead>
<tr>
<th></th>
<th ng-repeat="data in tablearray" colspan="2">{{data.heading}}</th>
</tr>
</thead>
<tr>
<td>Date</td>
<td ng-repeat="data in inventorarray"> <p ng-if="$index%2==0"> Last Reading</p><p ng-if="$index%2>0"> Read By</p> </td>
</tr>
<tr ng-repeat="data in tablearray">
<td> {{data.Date}}</td>
<td ng-repeat="data in inventorarray"> <p ng-if="$index%2==0"> {{data.Lastreading}}</p><p ng-if="$index%2>0">{{data.Readingby}}</p> </td>
</tr>
</table>
任何人都可以知道这个循环请在这里过去2天...我 需要今天完成请小提琴并发送给我