【问题标题】:How to pass parent key to child in nested *ngFor angular如何在嵌套 *ngFor angular 中将父键传递给子级
【发布时间】:2021-04-26 22:21:23
【问题描述】:

我需要将父循环的键传递给另一个数组。但它不起作用。下面是我的代码

<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 是另一个数组

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

contact_settings_title=[
    {'first':FirstTitle},
    {'second':SecondTitle}
]

【问题讨论】:

  • 你的意思是contact_settings_title[key]?究竟需要什么以及如何将密钥传递给另一个数组?
  • {{ contact_settings_title[con_settings.key] }} 不工作?
  • @MehranBeiglou 不,它不工作
  • @MikeS。我已经发布了数组,请检查

标签: angular foreach nested-loops ngfor


【解决方案1】:
<div  *ngFor="let con_settings of contact_settings | keyvalue">
 <h5 class="mt-0 task-header header-title">{{ contact_settings_title[key] }}</h5>
</div>

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 2017-08-23
    • 2020-08-23
    • 1970-01-01
    • 1970-01-01
    • 2021-01-11
    • 2018-01-15
    • 2019-08-24
    • 1970-01-01
    相关资源
    最近更新 更多