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.
如何在加载订单时获取相应的OrderItem?
angular .module('MyApp.services',['ngResource']) .factory('Order',function($resource) { return $resource('/api/v1/Order/:orderId?format=json',{},{}); }); .factory('OrderItem',function($resource) { return $resource('/api/v1/OrderItem/:orderitemId?format=json',{}); });
我在get order上尝试了一个回调函数来加载OrderItems,但是没有用.
有一个非常相似的问题,但它已经过时了:$resource relations in Angular.js