2

I have some logic in aura:if condition and I can't write condition below properly:

<aura:if isTrue='{!v.currentStage == '+'\"'+'General_Stage'+'\"'+}'>

I need render if currentStage == "GeneralStage". Problem is it should be in quotes

2 Answers 2

4

Since " is a reserved character, it is necessary to encode it inside attributes. In given scenario, &quot; should be used

For example,

    <aura:if isTrue="{!v.currentStage == '&quot;General_Stage&quot;'}">
    </aura:if>
0

You need an extra boolean variable to render your condition The Aura application

<aura:application >
    <aura:attribute type="String" name="currentStage" default="'GeneralStage'" />
    <aura:attribute type="Boolean" name="isGeneral" default="false"/>
    <aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
    <aura:if isTrue="{!v.isGeneral}">
        {!v.currentStage}
    </aura:if>
</aura:application>

The controller

({
    doInit: function(cmp) {
        if(cmp.get("v.currentStage") === "'GeneralStage'"){
            cmp.set("v.isGeneral",true);
        }
    }
})

What you are trying to do is not allowed as it will create an issue in parsing the aura component and it is not a safe character

You must log in to answer this question.

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