【发布时间】:2017-04-30 22:09:19
【问题描述】:
我的问题是由于缺乏使用 angular2 和 HTML5 的经验造成的,所以请不要怪我 ;) 我有一些这样的食物类别:
这是他们的 HTML:
<div
*ngFor="let item of items; let i = index"
class="col-lg-4 col-md-6 lc-reset-padding-v"
>
<md-card>
<md-card-title-group>
<md-card-title layout="row" layout-align="end center">
<div class="md-card-title-media inline">
<img
alt="{{item.picture.alt}}"
title="{{item.picture.title}}"
src="{{page_items_url + item.picture.public_id}}"
>
</div>
<div class="md-card-title-text inline">
<span class="md-headline inline">{{item.name}}</span>
<span *ngIf="item?.internal_reference">
<p class="md-headline-reference">
{{'ref' | translate}}: {{item.internal_reference | truncate : 22}}
</p>
</span>
<span *ngIf="item?.description">
<p class="md-subhead">{{item.description | truncate : 100}}</p>
</span>
<span
*ngIf="page?.advanced"
class="label label-pill item-type text-capitalize">
{{item.item_type || 'no type for this '}} item
</span>
</div>
<div *ngIf="item.out_of_stock" class="ribbon">
<span>{{'notAvailable' | translate}}</span>
</div>
<span class="price">
{{item.price | currency: item.official_currency:true:'1.2-3'}}
</span>
</md-card-title>
</md-card-title-group>
</md-card>
</div>
这些食物类型中的每一种都属于category(在每个食物对象中显示为对象参数),所以我希望食物的视图将按如下类别排序:
我在*ngFor 循环中添加了这些行:
<h3 class="text-muted text-uppercase title-container">
{{item.category.name}}
</h3>
但是,从逻辑上讲,它看起来像这样:
请提供任何帮助或指导或想法?
【问题讨论】:
-
你有什么问题/问题。
-
So I want that the View of foods will be ordered by categories like this one:.. 第二张图片.. -
这与 Angular 和 HTML 无关,它是纯算法。
标签: html algorithm loops angular ngfor