From my understanding of javascript, I should be able to query for map value using key using following code:
consts = {'key' : 'value'};
var stringKey = 'key';
var something = consts[stringKey];
However, when I try to use similar way of querying within an aura component to apply dynamic style for my button colour in the code below, I get an error.
Code:
<aura:iteration items="{!v.myObjs }" var="obj">
<aura:iteration items="{!obj.myItems }" var="objItem">
<div class="slds-col slds-small-size_12-of-12 slds-medium-size_6-of-12">
<button class="slds-button slds-button_neutral" style="{!'color:' + obj.btnColour[objItem.MyName__c]}" onclick="{!c.showFlow}" id="{!objItem.MyName__c}">{!objItem.MyText__c}</button>
</div>
</aura:iteration>
</aura:iteration>
Error:
FIELD_INTEGRITY_EXCEPTION - expecting a positive integer, found 'objItem' at column xx of expression: 'color:' + obj.btnColour[objItem.MyName__c]: Source
Am I doing anything wrong? I verified, I have my object correctly setup and it contains data as expected.