【发布时间】:2021-02-13 09:46:20
【问题描述】:
嗨,我有一个 html,我需要在 html 中传递对象名称/字符串。例如:
HTML
<app-family
(callDad) ="callFamily($event, {{family.Dad}})"" // I want to pass "Dad" as a string
(callSon) ="callFamily($event, {{family.Son}})"" // I want to pass "Son" as a string but get it from the object so it is not error prone
(callMom) ="callFamily($event, {{family.Mom}})"" // I want to pass "Mom" as a string
(callDaughter) ="callFamily($event, {{family.Daughter}})"" // I want to pass "Daugher" as a string
></app-customer>
组件类
export class Family {
family: Family;
}
型号
export class Family{
Dad: string
Mom: string
Son: string
Daughter: string
}
我想获取属性的名称并在 html 中传递它。像爸爸、妈妈、儿子和女儿一样?
【问题讨论】:
-
@DmitryS。不,我不是想获得价值,而是像爸爸,妈妈这样的实际对象字符串
-
@LearnAspNet 请检查我的答案,让我知道它是否适合您。最好的祝愿。 :-)
标签: angular typescript