title: AngularJS local storage - initialize app retrieving local-stored data
body: <p>I'm pretty new to angular and I'm trying to avoid losing items added on a simple cart application when the user refreshes the page.</p>
  
  <p>I'm using angularLocalStorage  (<a href="https://github.com/agrublev/angularLocalStorage" rel="nofollow noreferrer">https://github.com/agrublev/angularLocalStorage</a>) but don't know how to retrieve it back the content.
  My lines: </p>
  
  <pre><code>var myApp = angular.module('ionicApp', ['ionic','angularLocalStorage']);
  myApp.factory('prodottiData', function($http) {
    return {
      getFooOldSchool: function(callback) {
      $http.get('http://192.168.1.128/hongkongapp/?json=get_recent_posts&amp;post_type=product&amp;custom_fields=all').success(callback);
      }
    }
   });
  myApp.factory('DataService', function() {
    var myCart = new shoppingCart("AngularStore");
    return {
      cart : myCart
    };
  });
  myApp.controller('MyController', function MyController ($scope, storage, $ionicSideMenuDelegate, prodottiData, DataService, $sce) {
      $scope.toggleLeft = function() {
      $ionicSideMenuDelegate.$getByHandle('mainMenu').toggleLeft();
    };
    $scope.toggleMySecondMenuLeft = function() {
      $ionicSideMenuDelegate.$getByHandle('mySecondMenu').toggleLeft();
    };
      //adding menu data to the scope object
      prodottiData.getFooOldSchool(function(data) {
          $scope.menu = data;
      });
      //adding the cart to the scope object
      $scope.cart = DataService.cart;
      $scope.to_trusted = function(html_code) {
          return $sce.trustAsHtml(html_code);
      }
      images = $scope.menu;
      $scope.showloader = function(){            
              $scope.shownImage = this.post.thumbnail_images.full.url;
              $scope.itemDesc = this.post.content;
              $scope.itemPrice = this.post.custom_fields._price[0];
              $scope.productName = this.post.title;
              $scope.skuProdotto = this.post.id;
          }
      });
  </code></pre>
  
  <p>Now, if I check local storage on the console I can see something is really stored, but I miss the way to re-populate the cart at startup.</p>
  
  <p>Any help would be great!</p>