これは私が見つけた最も関連性の高いものです: https://stackoverflow.com/a/11972028/110233
1つだけ返したいときはうまくいくようですが、他のものが最初のものに依存しているときに複数のものを返す方法がわかりません。
それはちょっと鈍いので、私が現在行っていることの小さな例を次に示します。
window.EventRosterCtrl = ($scope, subevent) ->
$scope.subevent = subevent
EventRosterCtrl.resolve =
subevent: (SubEvent, $route) ->
deferred = $q.defer()
SubEvent.get {subevent_id: $route.current.pathParams.subevent_id}, (subevent) ->
deferred.resolve subevent
return deferred.promise
そして、これが私がやりたいことの例です:
window.EventRosterCtrl = ($scope, subevent, addresses) ->
$scope.subevent = subevent
$scope.addresses = addresses
EventRosterCtrl.resolve =
subevent: (SubEvent, $route) ->
deferred = $q.defer()
SubEvent.get {subevent_id: $route.current.pathParams.subevent_id}, (subevent) ->
deferred.resolve subevent
return deferred.promise
addresses: (User) ->
deferred = $q.defer()
# how do you get subevent called first and how would you access it here?
for participant in subevent.participants
User.get {user_id: participant.user}, (user) ->
addresses[participant._id] = user.address
deferred.resolve addresses
return deferred.promise