Html 使用ionic按日期分组聊天
我有一个ionic firebase聊天应用程序,我想像WhatsApp那样按日期对聊天进行分组,因此在聊天顶部有一个标记“今天”、“昨天”等。所有消息都有时间戳,但我需要一种方法来使用它们对消息进行分组。谢谢Html 使用ionic按日期分组聊天,html,firebase,ionic-framework,Html,Firebase,Ionic Framework,我有一个ionic firebase聊天应用程序,我想像WhatsApp那样按日期对聊天进行分组,因此在聊天顶部有一个标记“今天”、“昨天”等。所有消息都有时间戳,但我需要一种方法来使用它们对消息进行分组。谢谢 this.chatService.markAsSeen(); this.allMessages = []; this.allMessages = this.chatService.matchMessages; })``` ``` <ion-
this.chatService.markAsSeen();
this.allMessages = [];
this.allMessages = this.chatService.matchMessages;
})```
``` <ion-list no-lines>
<ion-item
no-lines
*ngFor="let item of allMessages; let i = index"
text-wrap
>
<div class="bubble me" *ngIf="item.sentBy === match.uid">
<h3 class="line-breaker">{{ item.message }}</h3>
<p class="time-me">{{ item.time }}</p>
</div>
<div class="bubble you" *ngIf="item.sentBy != match.uid">
<h3 class="line-breaker">{{ item.message }}</h3>
<p class="time-you">{{ item.time }}</p>
</div>
<div
class="seen"
*ngIf="item[matchUid] == 0 && item.sentBy !== match.uid"
>
Seen
</div>
</ion-item>
</ion-list>```
this.chatService.markAsSeen();
this.allMessages=[];
this.allMessages=this.chatService.matchMessages;
})```
```
{{item.message}}
{{item.time}
{{item.message}}
{{item.time}
看到
```
我们的聊天应用程序中也有同样的功能。对于HTML,请将以下内容放入您的ion项中:
<ion-row *ngIf="isDifferentDay(index)">
<ion-badge>{{getMessageDate(index)}}</ion-badge>
</ion-row>
不客气:)我们的聊天应用程序中也有同样的功能。对于HTML,请将以下内容放入您的ion项中:
<ion-row *ngIf="isDifferentDay(index)">
<ion-badge>{{getMessageDate(index)}}</ion-badge>
</ion-row>
不客气:)非常感谢,@wcjord。这正是我所需要的:-非常感谢,@wcjord。这正是我所需要的:-D