I have the following code in my HTML template for my Angular 6 application.
<div *ngIf ="conversation.participants[conversation.updatedBy.toLowerCase()].firstName">somedata </div>
My goal is to search within the participants array object based on the updatedBy value and check if the matching object has a non-null firstName property. However, I am getting an error saying that firstName is not defined.
I also tried adding a question mark after the closing square brackets as follows, but it did not give me any result:
conversation.participants[conversation.updatedBy.toLowerCase()]?.firstName
Here is the JSON object:
"participants": [{
"dateJoin": 1520409578,
"dateLeft": 0,
"firstName": "edh",
"internalId": 165,
"invitedBy": "edh",
"lastName": "edh",
"userId": "edh"
}, {
"dateJoin": 1520409578,
"dateLeft": 0,
"firstName": "",
"internalId": 166,
"invitedBy": "edh",
"lastName": "",
"userId": "ATB"
}],
"dataInAB": "ATB",
"subject": "test ",
"unreadMessageCount": 0,
"updateDate": 1520585258,
"updatedBy": "atb"
}
If you have any insights or solutions regarding this issue, please let me know.
Thank you.