like when i get return value from apex controller as a map(id,object) and i want to set it on an attribute. but its not happening. lengh is also not working.
lets say i have returned 5 object from apex controller, now
.cmp://only writing the attribute
<aura:attribute name="cartItemList" type="Object" />
JS controller:
var action = component.get('c.getCartItems');
action.setParams({
CartId : state.c__cartId
});
action.setCallback(this, function(response){
var state = response.getState();
alert(state);
if(state =='SUCCESS' || state == 'DRAFT'){
alert('result data only ' + response.getReturnValue().length); // **undefined**
var resultData=JSON.stringify(response.getReturnValue());
console.log('resultData from apex check :' + JSON.stringify(response.getReturnValue()));
var item=[];
for(var key in resultData){
item.push(resultData[key]);
}
component.set('v.cartItemList',item);
//**alert(item.length) is showing =1034**
kindly help.thanks in advance
thanks for answer quickly, but var itemList = Object.values(resultData); component.set('v.cartItemList',itemList); that also same thing happening alert(itemList.length); // returns 1019 but i want it to be 5
var action = component.get('c.getCartItems');
action.setParams({
CartId : state.c__cartId
});
action.setCallback(this, function(response){
var state = response.getState();
alert(state);
if(state =='SUCCESS' || state == 'DRAFT'){
alert('result data only ' + response.getReturnValue().length); //undefined
var resultData=JSON.stringify(response.getReturnValue());
console.log('resultData from apex check :' + JSON.stringify(response.getReturnValue()));
/*var item=[];
for(var key in resultData){
item.push(resultData[key]);
}*/
var itemList = Object.values(resultData);
component.set('v.cartItemList',itemList);
alert(itemList.length); ----1019
//component.set('v.cartItemList',item);
I have also made <aura:attribute name="cartItemList" type="LIst" /> // stil not working showing 1019 items in UI.
I am pasting the result from apex after stringify..
now what i want is to show is 5 items in UI...with Name. like below.
CR-00006 CR-00007 CR-00008 CR-00009 CR-00010