i am doing a bucle for to get the keys from local storage archives and i want to attach that keys to dynamically created elements the way that when i click over the new created element (who recives the name of the storage file) it will alert the content. This is what i have, the problem is in archivo[ keys[i] ].
function local(){
archivo = {};
keys = Object.keys(localStorage);
i = 0; var key;
for (i = 0; key = keys[i] ; i++) {
var compra_recuperada = document.createElement('ons-list-item');
compra_recuperada.innerHTML = keys[i];
document.getElementById('compra').appendChild(compra_recuperada);
archivo[ keys[i] ] = localStorage.getItem( keys[i] );
compra_recuperada.addEventListener('click', function(){ alert(archivo[ keys[i] ])
})}};