Getting request parameter in AngularJS Resource transformResponse function

I am trying to create a simple "database" in a json file and serve it with a function to get a specific item from a json array. I'm using the modified code sample from the angular tutorial:

var projectService = angular.module('projectService', ['ngResource']);

projectService.factory('Project', ['$resource', '$http',
function($resource, $http){
    return $resource('assets/data/projects.json', {id: '@id'}, {
        get: {
            method: 'GET',
            transformResponse: function(data) {
                //problem
            }
        }
    });
}]);

      

I see that the correct parameter is passed during the ajax call, the whole jQuery file is returned and I cannot access the url parameter to filter the array to get the correct object. Is there a way to access the url parameters in the transformResponse function?

+3


source to share





All Articles