The usual way of defining an isolated resource in AngularJS is:
angular.service('TheService', function($resource){
return $resource('api/url');
});
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 OrderItem
s. My first idea is this:
- Create the
OrderService
andOrderItemService
as independent resource models - Write a controller that queries the
OrderService
and watches the result array - When the result array changes, query the
OrderItemService
for all of the item IDs and decorate theorder
object with extended information as it comes in
That seems a bit messy. Is there a more elegant way?