【问题标题】:AngularJS Http-Service get no DataAngularJS Http-Service 没有数据
【发布时间】:2017-02-02 08:05:17
【问题描述】:

我使用 angularJs 和 Ionic,我想从 azure 获取数据。

“Winzer”表的链接是: https://winetastic.azurewebsites.net/tables/Winzer?ZUMO-API-VERSION=2.0.0

当我打开该链接时,我得到:

[{"id":"b15f5cf0-e576-4b6a-8fec-9e22a9e52630","createdAt":"2017-01-31T22:49:01.016Z","updatedAt":"2017-02-02T07:13:59.587Z","version":"AAAAAAAAHM4=","deleted":false,"Name":"Winzer 1","Streetname":"Straße 1","Address":"Adresse","Phone":null,"Mail":null,"URL":null,"Region":"Region ","Fax":null}]

我想在“离子列表”中显示属性“名称”

我的控制器如下所示:

.controller('winzerCtrl', ['$scope', '$stateParams', '$http', 'WineService', function ($scope, $stateParams, $http, WineService) { 
$http.get("https://winetastic.azurewebsites.net/tables/Winzer?ZUMO-API-VERSION=2.0.0").then(function (response) { $scope.winzerList = response.data.records; });}])

我的 html 网站如下所示:

<ion-list id="winzer-list9" class="manual-list-fullwidth">
  <ion-item ng-repeat="winzer in winzerList | filter:test "class="item-icon-left" id="winzer-list-item33" ui-sref="winetastic.winzerDetails">
    <i class="icon ion-android-contact"></i>{{winzer.Name}}</ion-item>

</ion-list>

当我运行项目时,我没有收到错误,但列表中没有显示任何数据。 怎么了?

【问题讨论】:

  • response.data 不保存您要分配给 winzerList 的数据,response.data.recordsundefined

标签: angularjs json http azure


【解决方案1】:

正如@Kasper Ziemianek 所说,你应该替换

$scope.winzerList = response.data.records; 

$scope.winzerList = response.data;

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 2014-08-10
    • 2018-05-07
    • 1970-01-01
    • 2016-12-09
    • 2018-03-09
    • 2017-12-15
    • 1970-01-01
    相关资源
    最近更新 更多