仅当我的条件为true时,才需要设置title=""
,如果根本不存在title
,则需要设置property.propertyKey === 'birthday'
。
因此,只有title
的{{1}}应该获得birthday
的值。
<div
*ngFor="let property of visibleCandidateProperties"
[title]="property.propertyKey === 'birthday' ? birthday">
{{candidate[property.propertyKey]}}
</div>
在上面的代码中,它不起作用,因为需要添加一些: false
条件。
我该如何重写?
(也许最好用.ts
文件而不是.html
重写,但仍然不知道怎么做)
非常感谢您的帮助!
答案 0 :(得分:1)
那怎么样?
<div
*ngFor="let property of visibleCandidateProperties"
[title]="property.propertyKey === 'birthday' ? birthday : ''">
{{candidate[property.propertyKey]}}
</div>