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)}" >
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;.

  • 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. – TemporaryFix Jan 15 '18 at 19:15
  • @Programatic Yeah you would have to use the entity &lt;= that isn't very readable. – Keith C Jan 15 '18 at 19:19
  • Thanks for documenting this stuff. I'd say Salesforce's documentation on this is rather misleading. – TemporaryFix Jan 15 '18 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 Jan 15 '18 at 19:24

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.