Search code examples
angularforeachnested-loopsngfor

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}
]

Solution

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