过滤对象数据angularjs
filter object data angularjs
我想通过条形码过滤我的库存,我可以这样做吗?这里的要点是,如果我传递的条形码等于库存[i]条形码(在服务器中),那么将$scope.inventories
更改为只有条形码匹配的条形码。然后是$scope。库存仅由匹配的条形码库存组成。
有一些疯狂的错误。任何帮助,如何过滤对象数据?
$scope.inventories = new Inventory().query().$object;
$scope.filter = function(barcode) {
for(var i = 0; i < $scope.inventories.length; i++){
if($scope.inventories[i].barcode == barcode){
$scope.inventories = $scope.inventories[i];
}
}
};
模板<ul ng-repeat="inventory in inventories">
<li><a href="" ng-click="filter(inventory.barcode)">{{inventory.barcode}}</a></li>
</ul>
为筛选项创建不同的变量名
$scope.filter = function(barcode) {
var filtered = [];
for(var i = 0; i < $scope.inventories.length; i++){
if($scope.inventories[i].barcode == barcode){
filtered.push($scope.inventories[i]);
}
}
$scope.filtered_inventories = filtered;
};
定义过滤器:
$scope.filterByBarcode = function(list, barcode) {
return list.filter(function(item){
return item.barcode === barcode;
});
};
过滤器在ng-repeat:
<ul ng-repeat="inventory in filterByBarcode(inventories, barcode)">
<li><a href="" ng-click="inventory">{{inventory.barcode}}</a></li> <!-- Not sure if this is what you want to display -->
</ul>
相关文章:
- OnsenUI AngularJS数据绑定无法正常工作
- 使用AngularJs数据绑定的三元运算符显示图像
- json的Angularjs数据,onclick,在右边显示相应的数据
- AngularJS数据绑定中断ngRepeat+奇怪行为
- 使用大括号的 Internet Explorer 上的 AngularJS 数据绑定问题
- Angularjs数据ng控制器
- AngularJS数据绑定与KnockoutJS数据绑定
- AngularJS数据在刷新后被“重置”
- 使用 D3js 时,带有 DOM 的 AngularJS 数据绑定不起作用
- AngularJS 数据绑定不会动态更新内容
- AngularJS:数据正在控制器中更新,但不显示在HTML中
- AngularJS数据绑定到按钮不起作用
- AngularJS:数据绑定和点表示法
- Angularjs 数据绑定失败,Angular UI-Bootstrap typeahead
- AngularJS数据转换
- 将 AngularJS 数据模型绑定到基础复选框
- 使用AngularJS数据表中的Scrolling按需加载数据
- 使用angularjs数据类型的json下拉选项正在附加
- AngularJS数据插入成功,但显示错误代码
- 控制器中的AngularJS数据绑定和在不同作用域上操作的模板