Hey there! I have an array that I am looping through and displaying the id as a link.
errMsg: string
const group = [
{
"name": "TSPM Process Connector Validation",
"values": [
{
"id": "10007017",
"url": "http://www.aol.com",
"component": "TSPM Process Connector Validation",
"requestSentStatus": 1,
"responseReceivedStatus": 1
},
{
"id": "10007016",
"url": "http://msn.com",
"component": "TSPM Process Connector Validation",
"requestSentStatus": 1,
"responseReceivedStatus": 1
}
]
},
{
"name": "TSPM Application Mapping Validation",
"values": [
{
"component": "TSPM Application Mapping Validation",
"requestSentStatus": 1,
"responseReceivedStatus": 0
},
{
"component": "TSPM Application Mapping Validation",
"requestSentStatus": 1,
"responseReceivedStatus": 0
}
]
}
]
getStatusMessage(group) {
if (group) {
for (const mappedObj of group.values) {
if (mappedObj.requestSentStatus === null || mappedObj.requestSentStatus === undefined) {
this.errMsg = 'Enqueued for pickup and processing.'
} else if (mappedObj.requestSentStatus === 0 ){
this.errMsg = 'Failure sending data to CM.';
} else if (mappedObj.requestSentStatus === 1) {
if (mappedObj.responseReceivedStatus === null || mappedObj.responseReceivedStatus === undefined) {
this.errMsg = 'CR generation awaited from CM.'
} else if (mappedObj.responseReceivedStatus === 0) {
this.errMsg = 'CR generation failed at CM.'
} else if (mappedObj.responseReceivedStatus === 1) {
this.errMsg = '';
}
console.log('errorMessage', this.errMsg);
}
}
}
}
HTML
<ol class="lmn-list-group lmn-list-group-initial">
<ng-container *ngFor="let value of group.values">
<li class="lmn-list-group-item" *ngIf="value.id; else crCreationFailTmp">
<a [href]="value.url" target="_blank" [mtTooltip]="value.id" placement="top">
{{ value.id}}
</a>
</li>
<div class="lmn-pb-2 lmn-font-size-xs bfaText">{{ value.name }}</div>
</ng-container>
</ol>
<ng-template #crCreationFailTmp>
<li class="lmn-list-group-item lmn-pl-3 lmn-text-danger">{{errMsg}}</li>
</ng-template>
I'm showcasing the ID with the link of URL, so if the ID is not present, instead I want to display a message based on the conditions mentioned in the function getStatusMessage. Essentially, I am checking multiple conditions in order to show different error messages based on the requestSentStatus and responseReceivedStatus values. However, even though I am implementing this, I am only seeing empty error messages without any content. Can anyone help me figure out what I am doing wrong?