gpt4 book ai didi

javascript - Angular.js ng-repeat 使用 json 没有数据

转载 作者:行者123 更新时间:2023-11-28 11:55:00 26 4
gpt4 key购买 nike

我正在开发一个项目,其中有一个 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
});
});

最佳答案

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

关于javascript - Angular.js ng-repeat 使用 json 没有数据,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/25649433/

26 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com