0

I'm having a problem using AngularJS resources.

I have a resource that looks like this:

loginModule.service('TestResource', function ($resource, $location) {
    var $scope = this;
    $scope.resource = $resource(window.location.path+'/:event', {event:'@event'});

    $scope.inputData = function(data1, data2, success){
        return $scope.resource.save({'event':'inputData'},{'data1':data1,'data2':data2},success);
    };

    return $scope;
});

And yes, I've tried using:

//  $scope.resource = $resource($location.path()+'/:event');
//  $scope.resource = $resource(window.location.path+'/:event');
//  $scope.resource = $resource(':event');

Firebug reports that the address this tries to send to is one of these two:

http://localhost/sandbox/test/undefined/inputData
http://localhost/sandbox/test/:event?event=inputData

What I want is an address of:

http://localhost/sandbox/test/inputData

What am I doing wrong? More specifically, what should I do to make it right?

6
  • did you try $resource('/:event'...)? Commented May 8, 2013 at 15:09
  • @akonsu That actually gives me http://localhost/inputData Commented May 8, 2013 at 15:14
  • what happens if you remove the slash? Commented May 8, 2013 at 15:15
  • @akonsu That one gives me http://localhost/sandbox/test/:event?event=inputData Commented May 8, 2013 at 15:21
  • 1
    wow. there is probably a bug. my next try would be ./:event Commented May 8, 2013 at 15:25

1 Answer 1

1

try $resource('./:event', ...)

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.