1

Does lightning only support conditional functions provided in this document?

Or can I use javscript conditional format?

Example:

<aura:if isTrue="{!or(!v.displayTodayOnly, and(lessthanorequal(v.beginningOfDay, registrant.startTime), lessthanorequal(registrant.startTime, v.endOfDay)))}" >

vs

<aura:if isTrue="{! !v.displayTodayOnly || (v.beginningOfDay <= registrant.startTime && registrant.startTime <= v.endOfDay)}" >

1 Answer 1

3

The Expression Operators Reference illustrates that you can use operators like <= (actually has to be &lt;=) and ! and ||. The implementation is unlikely to be the execution of the raw JavaScript so best stick to the documented operators and syntax only.

(I don't see ( and ) mentioned but they do appear in examples.)

See aura/aura-components/src/test/components/expressionTest/functions/functions.cmp for some example expressions that use entities like &amp; and &lt;.

4
  • hmmm tried doing this but am getting an error Message: The value of attribute "isTrue" associated with an element type "aura:if" must not contain the '<' character. Commented Jan 15, 2018 at 19:15
  • @Programatic Yeah you would have to use the entity &lt;= that isn't very readable.
    – Keith C
    Commented Jan 15, 2018 at 19:19
  • Thanks for documenting this stuff. I'd say Salesforce's documentation on this is rather misleading. Commented Jan 15, 2018 at 19:22
  • @Programatic I've run into this too; to be fair about the documentation, the page I linked to says "escape the <= operator to &lt;= to use it in component markup".
    – Keith C
    Commented Jan 15, 2018 at 19:24

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .