Trying to create a custom Navigation Bar and display menu entries based on user privileges.
I defined this attribute in my component:
<aura:attribute name="navItemPrivs" type="Map" default="{ Task: false }"/>
In the JS controller and helper I'm able to access and modify it using navItemPrivs['Task'], but when I try and use it inside an aura:if expression:
<aura:if isTrue="{!and(v.navItemLabel1 != undefined, v.navItemPrivs['Task'] == true}">
I get an error:
expecting a positive integer, found ''Task'' at column 50 of expression: and(v.navItemLabel1 != undefined, v.navItemPrivs['Task'] == true
I can't access it using v.navItemPrivs[0] because the "0" key isn't defined (nor do I want it to be).
Is there something I'm doing wrong and this isn't the way to do it? Because I don't see why I would not be able to access Map values if they exist in the framework..
v.navItemPrivs.Taskand that should work just fine. However what you can't do is bind to dynamically named keys (e.g. you can't dov.myMap[v.myKey]in Lightning so far). Be aware that under the current way Locker functions (as of Summer '16 Patch 10.0) if you want a Map/Object key binding to be successful the key must exist when you first push the object to thev.attributeit will reside in.