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.
I tried *ngFor="let x of measurementTableList"
but unfortunately it didn't work.
CodePudding user response:
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 }}
CodePudding user response:
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>