Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
811 views
in Technique[技术] by (71.8m points)

foreach - How to pass parent key to child in nested *ngFor angular

I need to pass the key of parent loop to another array. But it is not working . Below is my code

<div  *ngFor="let con_settings of contact_settings | keyvalue">
 <h5 class="mt-0 task-header header-title">{{contact_settings_title.key}}</h5>
</div>

contact_settings_title is another array

contact_settings=[
{'first':['1','2']}
{'second':['3','4']}
]

contact_settings_title=[
    {'first':FirstTitle},
    {'second':SecondTitle}
]
question from:https://stackoverflow.com/questions/65845348/how-to-pass-parent-key-to-child-in-nested-ngfor-angular

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)
<div  *ngFor="let con_settings of contact_settings | keyvalue">
 <h5 class="mt-0 task-header header-title">{{ contact_settings_title[key] }}</h5>
</div>

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...