1

I have the following setup

angular.module('xyz').factory('Bike', function (restmod) {
    return restmod.model('/bikes').mix({
        BikeParts: { hasMany: "BikeParts" },
        $extend: {
            Record: {
                savePart: function (part) {
                    this.BikeParts.$create(part);
                },
            }
        }
    });
});

Now if I have a bike with id 1 calling bike.savePart(part) creates a POST request to /bikes/1/bike-parts. I want instead that it posts to /bikes/1/parts/. Is there a way to do this (without renaming the BikeParts entry in the call to mix)?

Paul
  • 7,836
  • 2
  • 41
  • 48

1 Answers1

1

You should be able to change the url by adding a path property in your hasMany relation.

So change BikeParts: { hasMany: "BikeParts" } to BikeParts: { hasMany: "BikeParts", path: "parts" } and your url should become /bikes/1/parts/.