【发布时间】:2014-09-03 16:33:34
【问题描述】:
我有一个我正在做的项目,我有一个 json 数组(稍后将来自 Web 服务)
我正在尝试使用 ng-repeat 将该数据加载到表中。 (我以前做过,这次只是把我缺少的东西粘贴到我身上)
我在这里将代码发布到 github:https://github.com/sheets/Sch
我也很乐意在这里发布代码:
<body ng-app="MyApp">
<div ng-controller="SchCtrl">
<table class="table table-striped table-bordered">
<thead>
<th width="15%">Date and Time</th>
<th width="50%">Provider</th>
<th width="15%">Location</th>
<th width="10%">Map</th>
</thead>
<tbody>
<tr ng-repeat="appointment in appointments | orderBy:'startDatetime':true">
{{appointments.startDatetime | date:'MM/dd/yyyy HH:mm'}}
{{appointments.providerName}}
{{appointments.apptLocation}}</tr></tbody></table>
</div>
</body>
和 app.js:
var app = angular.module("MyApp", []);
app.controller("SchCtrl", function($scope, $http) {
$http.get('/appointments.json').
success(function(data, status, headers, config) {
$scope.appointments = data;
}).
error(function(data, status, headers, config) {
// log error
});
});
【问题讨论】:
-
一方面...你没有
<td>。 -
已删除以进行调试。
标签: javascript json angularjs