ngResource を使用して、建物を処理するための AngularJS サービスがあります。
angular.module('neighborhoodApp')
.factory('Building', function ($resource) {
return $resource('/areas/:aid/buildings/:id', {
'id': '@_id'
});
});
私の見解の 1 つでは、建物をリストします。
$scope.buildings = Building.query({
aid: $routeParams.aid
});
ルートからエリア ID を取得していますが、この情報はモデル内に保存されていないことに注意してください。
私の問題は、建物を表示するときに、エリア ID を使用したいのですが、アクセスできないことです。
<div ng-repeat="building in buildings">
{{building | json}}
<!-- 'building' doesn't include the area id
I can't modify the server response and somehow
I shouldn't have to, the information is inside the URL of the query()
Can I get URL params from the resource instance? -->
</div>