纯angularjs与restangular,用于消耗CRUD Restful资源
我正在用AngularJS编写一个客户端web应用程序,它使用RO-Isis服务器中的一些restful服务。 我正在考虑使用Spiro Angular客户端,在此过程中遇到了Restangular服务。。 请,我需要一些关于我是否更适合使用纯AngularJS或Restangular的指导。在实际的企业应用程序中使用这两种方法的利弊 注意:我的概念证明是从RO服务器创建、更新、删除和检索列表。 我有下面的工作为我的getList,但需要做完整的CRUD纯angularjs与restangular,用于消耗CRUD Restful资源,angularjs,restangular,isis,Angularjs,Restangular,Isis,我正在用AngularJS编写一个客户端web应用程序,它使用RO-Isis服务器中的一些restful服务。 我正在考虑使用Spiro Angular客户端,在此过程中遇到了Restangular服务。。 请,我需要一些关于我是否更适合使用纯AngularJS或Restangular的指导。在实际的企业应用程序中使用这两种方法的利弊 注意:我的概念证明是从RO服务器创建、更新、删除和检索列表。 我有下面的工作为我的getList,但需要做完整的CRUD sampleApp.controller
sampleApp.controller('XXXController', function($scope, $http) {
//Outer Restful call
$http({ method:'GET',
url: 'http://localhost:8080/XXX-webapp-1.0-SNAPSHOT/restful/services/XXXXX/actions/listAll/invoke',
headers: {'Accept': 'application/json'}
}).
success(
function (data) {
var resultType = data.resulttype;
var objects = data.result.value;
$scope.rowList= [];
console.log(objects);
if(resultType == "list"){
for(i=0; i < objects.length; i++){
//Inner Restful call
$http({ method:'GET',url: objects[i].href,headers: {'Accept': 'application/json'}
}).
success(
function (rowdata) {
$scope.rowList.push(rowdata);
}
);
}
}
}
);
});
sampleApp.controller('XXXController',函数($scope,$http){
//外部宁静的呼唤
$http({方法:'GET',
网址:'http://localhost:8080/XXX-webapp-1.0-SNAPSHOT/restful/services/XXXXX/actions/listAll/invoke',
标题:{'Accept':'application/json'}
}).
成功(
功能(数据){
var resultType=data.resultType;
变量对象=data.result.value;
$scope.rowList=[];
console.log(对象);
如果(结果类型==“列表”){
对于(i=0;i
如果您正在开发RestFul应用程序,那么最好使用angularngResource
http://docs.angularjs.org/api/ngResource/service/$resource
github read.me非常简单
与ngResource相比,我更喜欢使用Restangular。感谢您建议使用$resource,但我的主要问题是Restangular或AngularJS。我正在使用AngularJS ng资源开发RESTful应用程序。不使用restanglar。我对Restanglar不太熟悉。对我来说,到目前为止一切都很顺利ngResource是AngularJS的一部分,所以这个答案是相关的。当您发现纯$http太冗长时,$resource可以作为答案。Restangular也是一个不错的选择。另外,请记住.success是不推荐的,您应该使用.then。这还允许您链接您的承诺,这将减少上述内容所需的行数:)对于POC,转到angular$http,但对于专业应用程序,请使用restangular