In a component, initially i was binding a case picklist field value as an attribute. But now, i have requirement to bind it to a different field based on a boolean flag.
Original Code snippet (inside my component) which works fine
<c:CstmComp value={v.case.Field1__c}/>
CstmComp is another component embedded inside my component. It has a string attribute called value. We bind a picklist field Field1__c to it. CstmComp shows bunch of dropdown values which gets saved to Field1__c
Now i have to make it conditionally bind to Field1__c or Field2__c based on a boolean flag. I am trying following, but doesn't seem to work. Fields come out blank.
<aura:attribute name="flag" type="boolean" default="false"/>
<!--- flag gets read from a custom setting in doInit controller method -->
<c:CstmComp value={!v.flag?v.Case.Field1__c:v.Case.Field2__c}/>
What i expect is that when flag is true, the dropdown values displayed by CstmComp gets saved to Field1__c, and when it is false, it gets saved to Field2__c
Flag's value is getting set to true or false correctly, i have checked that. Dont know why none of the field gets bound to my CstmComp. Something wrong with the binding expression. Can someone help out?