【发布时间】:2013-10-23 09:44:54
【问题描述】:
我在 java 中编写了一个 restful 服务并从 angularjs 调用它,但它不起作用。如果我把静态 json 格式它的作品。但不适用于 RESTful 服务。以下是我在服务文件中的代码。
angular.module('intelesant.services', [])
.value('version', '0.1')
.service('customers1',function(){
return $resource('http://api.geonames.org/citiesJSON?north=44.1&south=-9.9&east=-22.4&west=55.2&lang=de&username=demo', {}, {
query: { method: 'GET', isArray: true },
create: { method: 'POST' }
})
});
我的控制器文件是
intelesant.controller('HomeController', ['$scope','customers1', function(s,customers) {
alert(JSON.stringify(customers));
s.homeContent = 'Test Content for Home page. This can come from server via REST service.';
}]);
【问题讨论】: