【发布时间】:2014-02-20 00:49:47
【问题描述】:
我有一个使用 ngResource 处理建筑物的 AngularJS 服务:
angular.module('neighborhoodApp')
.factory('Building', function ($resource) {
return $resource('/areas/:aid/buildings/:id', {
'id': '@_id'
});
});
在我的一个观点中,我列出了建筑物:
$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>
【问题讨论】:
标签: javascript angularjs angularjs-resource