2

Good day.

I have an API that produces this output:

(4) [{…}, {…}, {…}, {…}]
0:
    dueDate: "2018-03-26T00:00:00"
    priority: {priorityId: 1, priorityName: "Critical", priorityColor: "red"}
    statuses: Array(1)
    0:
          status: {statusId: 1, statusName: "New", statusColor: "lightblue", ticketStatuses: Array(0)}

In my Angular HTML Template:

<td mat-cell *matCellDef="let row"> {{ row.priority.priorityName }}</td>

Produces: Critical (as one would expect)

But in the following statement that has an additional array:

<td mat-cell *matCellDef="let row"> {{ row.statuses.status.statusName }}</td>

Produce ERROR TypeError: Cannot read property 'statusName' of undefined

I expected a result "New"

Hope someone can help me out here.

0

1 Answer 1

3

You need to use

<td mat-cell *matCellDef="let row"> {{ row.statuses[0].status.statusName }}</td>

since statuses is an array.

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.