i have two attributes in my component:
<aura:attribute name="sObjectName" type="String" />
<aura:attribute name="acc" type="Account" />
the attribute sObjectName contains the sObjectName (Lead, Account, Contact etc)
the attribute acc contains an Id,Name,Type.
when i write this line
<label>{!v.acc.Id}</label>
i receive the id of the account and it works great
when i write this line:
<label>{!v.sObjectName=='Lead' ? 'txtTest' : !v.acc.Id}</label>
when im in the lead record, it print 'txtTest' just fine, but when i'm not – it prints 'false' and not !v.acc.Id
what am i doing wrong? what is the correct syntax? Thanks
Best Answer
The reason that you are getting false is that the
v.acc.Id
is a javascript string, and the logical negation operator,!
, returns false when applied to strings.Basically, all you need to do is remove the
!
: