title: Uncaught Error: [$injector:unpr] Unknown provider Ionic Framework/AngularJS
body: <p>Following the <a href="http://learn.ionicframework.com/formulas/localstorage/">local storage tutorial on the Ionic blog</a>, I'm trying to set/get a localStorage value when my Ionic app runs but I get the error message:</p>
  
  <pre><code>Uncaught Error: [$injector:unpr] Unknown provider: $localstorageProvider &lt;- $localstorage
  </code></pre>
  
  <p>My app.js code:</p>
  
  <pre><code>angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
  
  .run(function($ionicPlatform, $localstorage) {
    $ionicPlatform.ready(function() {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      if(window.cordova &amp;&amp; window.cordova.plugins.Keyboard) {
        cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      }
      if(window.StatusBar) {
        // org.apache.cordova.statusbar required
        StatusBar.styleDefault();
      }
  
      $localstorage.set('name', 'Ian');
      console.log($localstorage.get('name'));
    });
  })
  </code></pre>
  
  <p>And services.js:</p>
  
  <pre><code>angular.module('starter.services', [])
  
  .factory('localstorage', ['$window', function($window) {
    return {
      set: function(key, value) {
        $window.localStorage[key] = value;
      },
      get: function(key, defaultValue) {
        return $window.localStorage[key] || defaultValue;
      },
      setObject: function(key, value) {
        $window.localStorage[key] = JSON.stringify(value);
      },
      getObject: function(key) {
        return JSON.parse($window.localStorage[key] || '{}');
      }
    }
  }]);
  </code></pre>
  
  <p>Not sure what I'm missing here.</p>
  
  <p><strong>EDIT</strong>:  If I change my app.js code to the following, it works as expected:</p>
  
  <pre><code>angular.module('starter', ['ionic', 'starter.controllers', 'starter.services'])
  
  .run(function($ionicPlatform, $localstorage) {
    $ionicPlatform.ready(function() {
      // Hide the accessory bar by default (remove this to show the accessory bar above the keyboard
      // for form inputs)
      if(window.cordova &amp;&amp; window.cordova.plugins.Keyboard) {
        cordova.plugins.Keyboard.hideKeyboardAccessoryBar(true);
      }
      if(window.StatusBar) {
        // org.apache.cordova.statusbar required
        StatusBar.styleDefault();
      }
  
      window.localStorage.setItem('name', 'Ian');
      console.log(window.localStorage.getItem('name'));
  
    });
  })
  </code></pre>