I'm just starting to learn Ionic and Angular, so I'm hoping someone can provide some guidance.
Here is the data I have:
"messages" : [
{
"sender" : "24",
"name" : "James",
"datetime" : ISODate("2019-11-10T20:42:02.090Z"),
"message" : "test 1",
"read" : [
{
"uid" : "24",
"name" : "James",
"datetime" : ISODate("2019-11-10T20:42:02.090Z")
},
{
"uid" : "45",
"name" : "Paul",
"datetime" : ISODate("2019-11-13T11:32:45.010Z")
}
]
}]
In my Ionic setup, I currently pass this data as 'mailbox' and 'uid' represents the user's ID.
<ion-item *ngFor="let message of mailbox">
<ion-item [routerLink]="['/members/mailbox', message.sid" routerDirection="forward">
{{ message.name}}
<br />Posted: {{ message.datetime }}
<div *ngIf="(message.read[0]['uid'] == uid || message.read[1]['uid'] == uid)">READ</div>
</ion-item>
</ion-item>
I'm looking for a more efficient way to write the ngIf condition since messages.read can have multiple entries. Is there a way to simply check if the 'uid' value exists in messages.read? I tried using Angular filter contains without success.
Thank you!