我创建了一个简单的demoapp,它似乎完美无缺。
demoapp使用restangular来获取请求。
/* the emp.json file from where the data is coming*/
[
{"id":1,
"subject":"#aashima"
},
{"id":2,
"subject":"#aansh"
},
{"id":3,
"subject":"#artle"
},
{"id":4,
"subject":"#harish"
}
]

<!doctype html >
<html ng-app="app">
<head>
<meta charset="UTF-8">
<title>Restangular</title>
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.5/css/bootstrap.min.css">
<script src="https://cdnjs.cloudflare.com/ajax/libs/angular.js/1.3.16/angular.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/underscore.js/1.8.3/underscore-min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/restangular/1.5.1/restangular.min.js"></script>
</head>
<body>
<div ng-controller="IndexCtrl as omega" ng-cloak>
<ul>
<li ng-repeat="result in omega.people">
<span ng-bind="result.subject"></span>
</li>
</ul>
<span ng-bind="omega.hero"></span>
</div>
<script>
var app = angular.module('app', ['restangular'])
.config(function(RestangularProvider) {
RestangularProvider.setBaseUrl("js");
});
app.controller('IndexCtrl', function( Restangular) {
var self=this;
Restangular.all('emp.json').getList().then(function(result) {
self.people = result;
});
});
</script>
</body>
</html>
&#13;
该应用程序运行良好但这里的问题是我的后端的json响应将是这样的
{&#34;用户&#34;:[ {&#34; ID&#34;:1, &#34受试者#34;:&#34;#aashima&#34; }, {&#34; ID&#34;:2, &#34受试者#34;:&#34;#aansh&#34; }, {&#34; ID&#34;:3, &#34受试者#34;:&#34;#artle&#34; } ] }`
我厌倦了将代码与这个json响应集成,Restangular是否支持这个json,如果确实如此,我需要一个不同的方法!!!