以下のようにUIを作成する必要があります。私はname alphabetically
を注文し、A
、B
のようにグループ化する必要があります。アルファベット順にグループ化する
Iは、以下に示すように(すなわち、アルファベット順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>
名前と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>
アドイン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
の設計や実装を教えすることはできますか?
Hmm ..私のユースケースでは、あなたのソリューションをどのように使用できますか?私は 'Contact'オブジェクトを持っています。 – Sampath
更新された回答のオブジェクトをループする方法を参照してください – Faly