0

I have an object as you have seen below, I want to get the data called measurementPointName from the measurement tables contained in this object, how can I print it to the screen using angular.

enter image description here

I tried *ngFor="let x of measurementTableList" but unfortunately it didn't work.

1
  • it would help if you shared some more of your controller code. But basically you need to set the output of your console log onto a variable in the controller. Furthermore you have an array in an array so you will need 2 ngFor directives Commented Nov 16, 2022 at 11:55

2 Answers 2

1

You'll need two *ngFor, one to cicle the "general array" of 2 elements and then one to cicle on measurementTableCalculations.

Into the second ngFor, you have to select the name field, so:

1: *ngFor="let SINGLE_ARRAY_ELEMENT of GENERAL_ARRAY_VARIABLE_NAME"

Assuming GENERAL_ARRAY_VARIABLE_NAME = worksList, you'll have: *ngFor="let work of worksList" and this is your first div

into that, you have to go for 2: *ngFor="let measurementTableCalculation of work.measurementTableCalculations" and print the field measurementTableCalculation.name where you want it, so:

{{ measurementTableCalculation.name }}

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

Comments

0

Your data returned as an array. You can access the data in the second index.

// your data
apiResult = [
  {
    workOderId: 1234
    ...
  },
  {
    measurementTableList: [
      ...
    ]
  }
];

you then can acces the needed data by either putting the second index in different variable or just do:

<div *ngFor="let x of apiResult[1].measurementTableList" ></div>

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.