0

`component :-

*ngFor="let ind of industryService.industries" value="{{ind.field[1].fieldName}}"`

How access fieldName in this collection object here

5
  • Does this answer your question? How can I access and process nested objects, arrays or JSON? Commented Jul 17, 2020 at 7:37
  • @VLAZ it's printing [object object] Commented Jul 17, 2020 at 7:48
  • You just want to show the first element so you should write [value]="ind.field[0].field_id.fieldName" Commented Jul 17, 2020 at 7:49
  • Thanks a lot @Emilien you are correct :-) Commented Jul 17, 2020 at 7:52
  • @Govi-BoySL Let me post it as an answer Commented Jul 17, 2020 at 7:53

1 Answer 1

1

In order to do that, you will need to go deeper throught your object :

[value]="ind.field[0].field_id.fieldName"

And if you want to ngFor of field :

<div *ngFor="let ind of industryService.industries; let i = index" [value]="ind.field[index].field_id.fieldName">
  <div *ngFor="let fieldItem of ind.field>
    <p>{{ fieldItem.fieldName }}</p>
  </div>
</div>
Sign up to request clarification or add additional context in comments.

2 Comments

hey can I get all fieldNames in the field array object? how?
You will have to ngFor of field. Maybe try something like : ts <div *ngFor="let ind of industryService.industries" [value]="ind.field[0].field_id.fieldName"> <div *ngFor="let item of ind.field"> <p>{{ item.fieldName }}</p> </div> </div>

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.