Angular 有条件地设置标题(角度)

Angular 有条件地设置标题(角度),angular,binding,title,Angular,Binding,Title,我需要设置title=”“,只有当我的条件为true时才需要设置,如果没有,则根本不应该有title。 因此,只有当property.propertyKey===“生日”时,title才应获得birthday值 <div *ngFor="let property of visibleCandidateProperties" [title]="property.propertyKey === 'birthday' ? birthday">

我需要设置
title=”“
,只有当我的条件为true时才需要设置,如果没有,则根本不应该有
title
。 因此,只有当
property.propertyKey===“生日”
时,
title
才应获得
birthday

<div
  *ngFor="let property of visibleCandidateProperties"
  [title]="property.propertyKey === 'birthday' ? birthday">

  {{candidate[property.propertyKey]}}
</div>

{{candidate[property.propertyKey]}
在上面的代码中,它不起作用,因为需要添加一些
:false
条件。 我怎样才能重写它? (也许在
.ts
文件中重写会更好,而不是
.html
,但仍然不知道如何做)

如果有任何帮助,我将不胜感激

怎么样


{{candidate[property.propertyKey]}

我使用
visibleCandidateProperties
{{candidate[property.propertyKey]}}行中显示整个数据列表(不仅仅是生日)
。只有在
propertyKey===“生日”
的情况下,我想将特定值设置为
title
。此筛选器将对此产生影响。请查看我的更新