0

Controller.js:

service.getUsers(params).$promise.then(function(response) {
    var data = response;
    $scope.users = data.resources;
    $scope.totalItems = data.totalResults;
});

Service.js:

return $resource('/Users', {}, {
            getUsers: {
                method: 'GET',
                headers: {'segment' : 'computedSegment'},
                isArray: true,
                transformResponse: function(data, header){
                    var wrapped = angular.fromJson(data);
                    angular.forEach(wrapped.resources, function(item, idx) {

                        wrapped.resources[idx] = item;
                    });

                    var deffered = $q.defer();
                    deffered.resolve(wrapped);



                    return deffered.promise;
                }
            }});  

The issue i am getting, is that although the request goes to the server, i receive a response, the data is correctly processed, the ,,then" function will never be executed to set the $scope variables.

Does anyone have an idea?

1 Answers1

0

I guess you forgot to use query() method after getUsers method. And I think you don't need to use promise in transformResponse method. You can check this answers.

Community
  • 1
  • 1
Ali BARIN
  • 1,870
  • 19
  • 22