模板文件未显示服务文件中的数据,有人可以检查代码并纠正我。谢谢你。
我还检查了数据是否由控制器传递,这正在发生。但是除了索引之外什么都没有显示。我以多种方式尝试了数据绑定,但问题似乎仍在重复。
html
<div class="panel3 panel-primary">
<div class="panel-heading">Documents</div>
<table class="table table-bordered table-condensed table-striped">
<tr>
<th>Serial Number</th>
<th>Document Type</th>
<th>Document Date</th>
<th>Status</th>
<th>Last Update Date</th>
</tr>
<tr ng-repeat="file in selectedDoc">
<td>{{$index+1}}</td>
<td>{{file.id.s.documentType}}</td>
<td>{{file.id.s.documentDate}}</td>
<td>{{file.id.s.status}}</td>
<td>{{file.id.s.lastUpdateDate}}</td>
</tr>
</table>
</div>
控制器
"use strict";
angular.module("fleetDocumentsModule").controller("fleetDocumentsController",
['$scope', 'fleetDocumentsService',
function ($scope, fleetDocumentsService) {
$scope.selectedDoc = fleetDocumentsService.getDocuments();
console.log("inside service file", $scope.selectedDoc)
}]);
服务文件
"use strict";
angular.module("fleetDocumentsModule").service("fleetDocumentsService",
function () {
this.getDocuments = function () {
return documents;
};
var documents = [
{
"id": "1",
"s":[{
"documentType": 'POD',
"documentDate": '01-12-2015',
"status": 'Printed',
"lastUpdateDate": '28-12-2015'
},
{
"documentType": 'SIM',
"documentDate": '01-12-2015',
"status": 'Printed',
"lastUpdateDate": '28-12-2015'
}
]},
{
"id": "2",
"s": [{
"documentType": 'DOC',
"documentDate": '01-12-2015',
"status": 'Printed',
"lastUpdateDate": '28-12-2015'
},
{
"documentType": 'LLTM',
"documentDate": '01-12-2015',
"status": 'Printed',
"lastUpdateDate": '28-12-2015'
}
]},
{
"id": "3",
"s": [{
"documentType": 'TOM2',
"documentDate": '01-12-2015',
"status": 'Printed',
"lastUpdateDate": '28-12-2015'
},
{
"documentType": 'TOM3',
"documentDate": '01-12-2015',
"status": 'Printed',
"lastUpdateDate": '28-12-2015'
},
{
"documentType": 'TOM4',
"documentDate": '01-12-2015',
"status": 'Printed',
"lastUpdateDate": '28-12-2015'
}
]},
{
"id": "4",
"s":[{
"documentType": 'TTL',
"documentDate": '01-12-2015',
"status": 'Recieved',
"lastUpdateDate": '28-12-2015'
}],
},
{
"id": "5",
"s":[{
"documentType": 'RET',
"documentDate": '01-12-2015',
"status": 'Printed',
"lastUpdateDate": '28-12-2015'
}],
}
]});