2

I am working on writing a client web application in AngularJS which consumes some restful services in an RO Isis server. I was looking at using Spiro Angular client and in the process came across the Restangular service .. Please, I need some guidance on if I am better of using pure AngularJS or Restangular. Any pros and cons for using EITHER in a real enterprise application.

NB: My proof of concept is create, update, delete and retrieve a list from an RO server. I had the following working for my getList, but need to do the full CRUD

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);
                }
              );
            }
          }
        }
      );
    });
user2722614
  • 21
  • 1
  • 7

2 Answers2

1

The github read.me is pretty straight forward...

https://github.com/mgonto/restangular#starter-guide

I prefer Restangular over ngResource for ease of use.

dsmithco
  • 351
  • 5
  • 7
0

If you are developing RestFul application then it is better to use angular ngResource

http://docs.angularjs.org/api/ngResource/service/$resource
rajmohan
  • 1,618
  • 1
  • 15
  • 36
  • Thanks for suggesting use of $resource, but my main question was Restangular or AngularJS. – user2722614 Mar 03 '14 at 12:59
  • I am developing RESTful application using just angularJs ng-resource. not using RestAngular. I am not that much familiar with RestAngular. For me everything is working fine till now. :) – rajmohan Mar 03 '14 at 13:05
  • ngResource is part of AngularJS, so this answer is relevant. When you find plain $http too verbose, $resource can be an answer. Restangular is a good alternative as well. Also, keep in mind that .success is deprecated, and that you should use .then instead. This also allows you to chain your promises, which will decrease the number of lines needed for the above :) – Jan-Willem Gmelig Meyling Jun 09 '16 at 19:25