I was testing Javascript Object Types and trying to bind them to aura attribute Collection types unsuccesfully client-side (for the most case), so I was wondering if there is a reference with a set of documented examples for each.
- type[] (Array)
- List
- Map
- Set
for a Map, I tried:
var myMap = new Map();
myMap.set("keyString", "value associated with 'a string'");
component.set('v.attMap', myMap);
for a Set:
var set1 = new Set([1, 2, 3, 4, 5]);
component.set('v.mySet', set1);
List and type Arrays:
var array1 = ['a', 'b', 'c'];
component.set('v.myList', array1);
The only Object Types I was able to successfully bind were the List and Type Array(s).
I based my examples out of JavaScript data types and data structures
When I Try Binding my server response to a Map/Set I am able to do so successfully.
I did notice that my Proxy object(s) for Map and Set were returning the following Exception:
Exception: TypeError: Method get Map.prototype.size called on incompatible receiver # at Map.get size [as size] () at Map.remoteFunction (:2:14)
minimal reproduceable code sample:
Component.cmp
<aura:component >
<aura:handler name="init" value="{!this}" action="{!c.doInit}"/>
<aura:attribute name="attMap" type="Map"/>
<aura:iteration items="{!v.attMap}" var="map">
<tr>
<td scope="row" data-label="Map Values">
<div class="slds-truncate" title="{!map}"><a href="javascript:void(0);">{!map}</a></div>
</td>
</tr>
</aura:iteration>
</aura:component>
Controller.js
({
doInit : function(component, event, helper) {
var myMap = new Map();
myMap.set("keyString", "value associated with 'a string'");
component.set('v.attMap', myMap);
//--->console.log(component.get('v.attMap'));
},
})
What would be the proper way of Binding Javascript Maps and Sets to Aura Collection Type Attributes? (an explanation backed up by documentation from the aura framework would be nice)