使用angularjs显示按类别排序的图像网格
Displaying a grid of images sorted by category using angularjs
我正在使用angular构建一个web应用程序,我想显示按类别排序的项目网格。每一行对应一个特定的类别。我的代码是这样的:
<ion-item ng-repeat="item in items|filter:query|orderBy:'name' ">
<div class="row" ng-scrollable style="width:400px;height:300px;">
<div class="col">
<img ng-src={{item.img}}/>
<p>{{item.name}}</p>
<p>Old Price: {{item.newPrice}}</p>
<p>New Price: {{item.newPrice}}</p>
<button class ="button" ng-click="addToGrocery()">Add to List</button>
</div>
</div>
我的controller.js文件是这样的:
.controller('CouponsCtrl', function($scope) {
$scope.items = [{ name: 'Banana', newPrice: 3.29, oldPrice: 4.49, aisle: 'A', img: 'http://placehold.it/280x150', category: 'Fruits' },
{ name: 'Chocolate', newPrice: 3.19, oldPrice: 5.39, aisle: 'B', img: 'http://placehold.it/280x150' , category: 'Dairy'},
{ name: 'Brocolli', newPrice: 2.29, oldPrice: 4.40, aisle: 'D', img: 'http://placehold.it/280x150' , category: 'Vegetables'}
];
})
我相信我需要嵌套的ng-repeat,但我不确定如何合并。
基于groupby使用AngularJs进行分组详细信息ng-repeat
<body ng-controller="con">
<div ng-repeat="(setKey, set) in items|filter:query|orderBy:'name'|groupBy:'category'">
{{setKey}}
<div ng-repeat="item in set">
<div class="row" ng-scrollable="" style="width:400px;height:300px;">
<div class="col">
<img ng-src="{{item.img}}/" />
<p>{{item.name}}</p>
<p>Old Price: {{item.newPrice}}</p>
<p>New Price: {{item.newPrice}}</p>
<button class="button" ng-click="addToGrocery()">Add to List</button>
</div>
</div>
</div>
</div>
</body>
http://plnkr.co/edit/GMW52iJyRlQ2otZndGLM?p =预览
相关文章:
- Javascript排序的图像弹出窗口..可以't单独弹出
- 我该如何使网页上的图像网格可排序
- 抽搐流图像并仅在在线流上排序
- Jquery 表排序不适用于图像
- 如何按维度对图像进行排序
- 具有排序问题的流体动态图像布局
- 使用Stupid表插件对图像进行排序
- 使用radio和jQuery对图像进行排序
- 如何在metro.js中实现图像重新排序
- 如何使jQuery中的图像可排序元素可拖动
- 在上传图像之前,对它们进行排序
- 气泡根据图像的名称对其进行排序
- dataTables如何添加排序图像/图标
- 使用数据库与文件系统进行图像排序
- Dropzone图像重新排序
- 重新排序ul li与图像
- n -repeat track by $index打破图像字段排序
- Dojo DataGrid:不对列中的图像进行排序
- 动态图像排序和裁剪类似于google+相册视图
- 使用Jssor滑块对图像进行排序并显示结果