2014-09-03 25 views
0

我有一个项目,我就在那里我有一个JSON阵列的工作(这在以后从Web服务)Angular.js使用JSON

,我试图用NG-重复NG-重复没有数据将该数据加载到表中。 (我以前做过这个,这个时候它只是滑倒贴上我,我错过了什么)

我贴的代码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 
     }); 
}); 
+0

一件事......你有没有''​​。 – MikeSmithDev 2014-09-03 16:41:06

+0

删除以进行调试。 – 2014-09-03 16:43:50

回答

2

你可以看看this simple exaple
1.你需要用在TD标记所有的数据
2.访问您的数据 - 你需要做的,像data.appointments
3.在ng-repeat你需要访问的每个项目在约会阵列 - 所以这是appointment

3

尝试访问appointment.startDatetime,而不是appointments.startDatetimeproviderNameapptLocation相同。基本上在约会中删除s

2

它不应该是

$scope.appointments = data.appointments 

? 然后你必须访问

appointment.<field_name>