Quantcast
Channel: Ionic Framework - Ionic Forum
Viewing all articles
Browse latest Browse all 49186

Problem with localStorage

$
0
0

@roma35 wrote:

hi I need your help please.

I have a problem with my controller and my factory my code is here:

this is my factory
` var zupa_io = angular.module('zupa.zfactory', []);

zupa_io.factory('zupafactory',function($http){

   // in here I retrieve my data in localStorage
   var products = angular.fromJson( window.localStorage['zupacart'] || '[]' );

    // in here I store my data in localStorage
          function zupapersist(){
            window.localStorage['zupacart'] = angular.toJson(products);
        }
    return {
      // this is my function for save
          ZupaSaveCart:function(prod){

            products.push(prod);
            zupapersist();
            console.log(products);
        },
    }

});`
my problem is when a try save my data, show me this error (products.push is not a function) but de products is present.
please help me

Posts: 1

Participants: 1

Read full topic


Viewing all articles
Browse latest Browse all 49186

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>