robin
robin

Reputation: 1925

Angular Js $Resource issue

Hi I am having the below in my factory

var MyResource = function($resource){
var MyResources  =  $resource('/test/rest/tests/activities/:userId',
  {
    userId: '@userId'
  },
  {
     query: {isArray: false}
  }
  );
  return MyResources ;
};

And I am calling the method like

MyResource.get({userid:$stateParams.userId})
    .$promise.then(function(data) {
            $scope.week1 = data.total1;
            $scope.total1 = data.totalAll1;
            monthArray = data.tasksMonth;
            console.log(monthArray);
            init();
  });

If the value of $stateParams.userId is testUser, I want the url like below

/test/rest/tests/activities/testUser

But now am getting a url like below

/test/rest/tests/activities?userId=testUser

Upvotes: 0

Views: 35

Answers (1)

Jesús Quintana
Jesús Quintana

Reputation: 1813

The objects in Javascript are case sensitive, your are using:

MyResource.get({userid:$stateParams.userId})

Instead of :

MyResource.get({userId:$stateParams.userId})

Where the userId change from userid to userId (I is in uppercase)

Upvotes: 2

Related Questions