0

I am unsure of what I am missing here...

So I have a child component with an attribute:

<aura:attribute name="recordClosed" type="Boolean" />

In the component I am doing something like this:

<aura:iteration items="{!v.recordData}" var="recordField">
    <aura:if isTrue="{!recordField.isDescription == false || (recordField.isDescription &amp;&amp; v.recordClosed == false)}">
        <lightning:layout>
            <!--some html-->
        </lightning:layout>
    </aura:if>
</aura:iteration>

The problem is with recordClosed. In my parent, I pass in the value for recordClosed when I create the component.

Now, if I add {!v.recordClosed} above the aura:if, it will print out 'false' on in my component. If I do {!v.recordClosed == false}, it will still spit out false... So my aura:if is failing when it should be true.

It says the value for recordField.isDescription is true and recordClosed is false, but the recordClosed comparison fails. It even does it when it is true and compared to true.

I even tried using {!not(v.recordClosed)}, it still fails to spit out true even though recordClosed is false.

2
  • Does this work- {!and(recordField.isDescription, !v.recordClosed)}, not sure if it does some kind of type check (which would be rather odd). Otherwise try with adding default="true" to the attribute. If nothing works, kindly share minimal code for us to replicate the behavior.
    – Raul
    Jan 4, 2019 at 15:31
  • I ended up finally figuring out the issue. How I was grabbing the value to pass to recordClosed was actually ending up converting it to a String type. Jan 4, 2019 at 15:48

1 Answer 1

0

Well, it looks like I wasn't going back far enough to diagnose the issue.

My parent component constructs anchor elements with data attributes, which is where I was storing my value for recordClosed:

<a href="javascript:void(0);" data-isclosed="{!data.isClosed}" onclick="{!c.createChild}"></a>

Then when that was clicked, I would get isclosed attribute doing event.target.dataset.isclosed and was passing that to my child component when I created it.

Turns out, doing it this way ends up converting the type of isclosed to String. So I was passing a string to the Boolean attribute in my child, causing it to not know how to compare it.

You must log in to answer this question.

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