Angularjs $resource 不适用于从 REST API 返回的数组 [英] Angularjs $resource not working with an array returned from a REST API
本文介绍了Angularjs $resource 不适用于从 REST API 返回的数组的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!
问题描述
我正在尝试学习 angularjs,并且在尝试将数据绑定到从 Rest API 返回的数组时遇到了障碍.我有一个简单的 azure api 返回一组人员对象.服务 URL 是 http://testv1.cloudapp.net/test.svc/persons.
我的控制器代码如下:
angular.module("ToDoApp", ["ngResource"]);函数 TodoCtrl($scope, $resource) {$scope.svc = $resource('http://testv1.cloudapp.net/test.svc/persons', {回调:'JSON_CALLBACK'}, {得到: {方法:'JSONP',isArray: 真}});$scope.items = $scope.svc.get();$scope.msg = "你好世界";}
我的 html 看起来像:
<头></头><身体><div ng-app="ToDoApp"><div ng-controller="TodoCtrl"><h1>{{msg}}</h1><table class="table table-striped table-condensed table-hover"><头><th>电子邮件</th><th>名字</th><th>Last Name</th></thead><tr ng-repeat="项目中的项目"><td>{{item.Email}}</td><td>{{item.FirstName}}</td><td>{{item.LastName}}</td></tr></tbody>