-
Notifications
You must be signed in to change notification settings - Fork 26
Open
Labels
Description
The HyperlinkedModelSerializer produces urls for related objects like that:
{
url: "http://localhost:8000/orders/1/"
cargo: "http://localhost:8000/cargo/1/"
}
Therefore a REST client needs no prior knowledge about url schema. But code for the navigation some annoying:
var Order = djResource('/orders/:order_id', {order_id: '@id'});
var orders = Order.query();
orders.$then(function(response) {
angular.forEach(response.data, function(order) {
var cargoUrl = order.cargo;
// prevets port stripping from url
// see https://github.com/angular/angular.js/issues/1243
cargoUrl = cargoUrl.replace(/(:\d)/, '\\$1');
order.cargo = djResource(cargoUrl).query();
}
});
$scope.orders = orders;
Reactions are currently unavailable