【发布时间】:2014-04-10 09:21:24
【问题描述】:
我想过滤数据,从api获取数据,但是不行,有什么解决办法吗?
$scope.filter_all2 = function(value) {
$scope.filtered_inventories = new Inventory().query({model: value, manufacturer: value}).$object;
};
我的模板
<select ng-model="inventory.model" ng-change="filter_all2(inventory.model)">
<option value="">Model</option>
<option ng-repeat="inventory in inventories | unique:'model'" value="{{inventory.model}}">{{inventory.model}}</div>
</select>
<select ng-model="inventory.manufacturer" ng-change="filter_all2(inventory.manufacturer)">
<option value="">Manufacturer</option>
<option ng-repeat="inventory in inventories | unique:'manufacturer'" value="{{inventory.manufacturer}}">{{inventory.manufacturer}}</div>
</select>
编辑:
Tastypie api,信息。
class InventoryResource(ModelResource):
assigned = fields.ForeignKey('bos_inventory.api.AssignedResource', 'assigned', full=True, null=True)
location = fields.ForeignKey('bos_inventory.api.LocationResource', 'location', full=True, null=True)
tags = fields.ToManyField(TagResource, 'tags', full=True, null=True)
class Meta:
queryset = Inventory.objects.all()
resource_name = 'inventory'
list_allowed_methods = ['get', 'put', 'post', 'delete', 'copy']
detail_allowed_methods = ['get', 'put', 'post', 'delete', 'copy']
authorization = DjangoAuthorization()
authorization = Authorization()
serializer = Serializer()
filtering = {'id': ALL, 'barcode': ALL, 'model': ALL, 'manufacturer': ALL, 'location': ALL, 'tags': ALL, 'assigned': ALL, 'inventory': ALL}
【问题讨论】:
-
您必须在服务器上过滤查询。服务器需要解释查询参数并返回过滤结果。这与javascript、angularjs、api、restangular无关
标签: javascript angularjs api restangular