I\'m trying to figure out the best way to write a model that relates to other models, such as an Order that has 1 or more OrderItems.
Ho
You could wrap the function in another that gets order items?
myApp.factory('Order', function($resource) {
var res = $resource('/api/Order/:orderId', {}, {
'_get': { method: 'GET' }
});
res.get = function(params, success, error) {
return res._get(params, function(data) {
doOrderItemStuff();
success(data);
}, error);
}
return res;
}
Before Andy's answer, I was workarounding it in Controllers. To do this, just add:
function OrderCtrl($scope, $routeParams, $resource, Order, OrderItem) {
$scope.order = Order.get({
orderId : $routeParams.orderId
}, function(order) {
doOrderItemStuff();
});
}