html5 - angularjs localstorage displaying data -


i been tryi'n use angular nowadays. i'm hoping if me why cant fetch localstorage data below codes.

[     {     "name": "firstname",     "email": "email@yahoo.com"     } ] 

service.js

 getitem: function (item) {        var temp =  localstorage.getitem(item);        if (!temp){         return [];       }        return json.parse(temp);   } 

controller.js

 profile.push({                 name: 'firstname',                 email: 'rmail@yahoo.com'  });  localstorage.setitem('profiles', json.stringify(profile));   console.log(service.getitem('name') + ' : should output name');  console.log(service.getitem('email') + ' : should output email'); 

can please try this

var array = service.getitem('profiles'); for(var i=0;i<array.length;i++){      console.log(array[i].name, array[i].email)  }  

Comments

Popular posts from this blog

monitor web browser programmatically in Android? -

Shrink a YouTube video to responsive width -

wpf - PdfWriter.GetInstance throws System.NullReferenceException -