$resource relations in Angular.js [updated]

后端 未结 2 841
难免孤独
难免孤独 2021-01-06 08:20

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

2条回答
  •  無奈伤痛
    2021-01-06 08:31

    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();
        });
    
    }
    

提交回复
热议问题