我正在使用Tastypie
过滤后端数据
class Meta:
queryset = Inventory.objects.all()
resource_name = 'inventory'
filtering = {'barcode': ALL}
api/v1/inventory/?format=json&barcode=1232141542625235624
中的我按barcode
如何使用它并使用AngularJS在前端过滤它?
app.controller('InventoryListCtrl', function($scope, Inventory, Restangular, inventoryItems) {
$scope.inventories = inventoryItems;
};
我的国家
app.config(function config( $stateProvider, $urlRouterProvider) {
$stateProvider.state('inventory',{
url:'/inventory',
views: {
"main": {
controller: 'InventoryCtrl',
templateUrl: 'inventory/main.tpl.html'
}
},
data:{ pageTitle: 'Inventory' }
}
).state('inventory.listview',{
url:'/listview/',
views: {
"listview": {
controller: 'InventoryListCtrl',
templateUrl: 'inventory/inventory.listview.tpl.html'
}
},
data:{ pageTitle: 'Listview' },
resolve: {
inventoryItems: function(Inventory, $stateParams){
return new Inventory().query();
}
}
})
拥有我的模板
<ul style="list-style:none;">
<li>{{inventory.manufacturer}} {{inventory.model}}</li></a>
<li><b>Barcode:</b> {{inventory.barcode}}</li>
<li><b>Holder:</b> {{inventory.user.first_name}} {{inventory.user.last_name}}</li>
<li><b>Tags:</b> {{inventory.tags.tags}}</li>
</ul>