【发布时间】:2018-04-18 16:27:25
【问题描述】:
我需要创建如下所示的 UI。我需要订购name alphabetically 并且需要像A、B 等分组。
我已经完成了第一部分(即使用lodash 按字母顺序排列名称),如下所示。
contacts.html
<ion-list>
<ion-item *ngFor="let c of contacts | async">
<name-and-rating item-start [data]="c"></name-and-rating>
<ion-input type="text" text-right disabled="true" [value]="c.company">
</ion-input>
</ion-item>
</ion-list>
name-and-rating.html(组件)
<div>
<div>
{{data.name}}
</div>
<div>
<rating [ngModel]="data?.rating" (ngModelChange)="data.rating=$event" readOnly="true" max="5" emptyStarIconName="star-outline"
halfStarIconName="star-half" starIconName="star" nullable="false" name="rating" item-end>
</rating>
</div>
</div>
add-contact.ts
addContact() {
this.storage.get('contacts').then((val: Contact[]) => {
this.contacts = val;
if (this.contacts == null) this.contacts = [];
this.contacts.push(this.data);
const sortedContacts = orderBy(this.contacts, [c => c.name.toLowerCase()], ['asc']);
this.storage.set('contacts', sortedContacts).then((val: Contact[]) => {
this.close();
});
});
}
contact.ts
export class Contact {
id: string;
name: string;
company: string;
phone1: number;
phone2: number;
email: string;
rating: number;
comments: string;
}
你能告诉我如何在第一张图片上设计或实现alphabetically grouping吗?
【问题讨论】:
标签: angular typescript ionic-framework sass ionic3