我已经在java中编写了一个restful服务,并从angularjs调用它,但它不工作。如果我把静态json格式的作品。但不适用于RESTful服务。以下是我在服务文件中的代码。如何从angularjs调用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.';
}]);
对不起的计算器代码的东西不喜欢我的贴,但看到小提琴。由于使用模拟帐户进行了多次访问,因此运行时出现错误,但似乎正常工作。 –