title: How to clear localstorage data in ionic?
body: <p>Here is my code.</p>
  
  <pre><code>$scope.logout=function(){
      localstorage.set('user_id', "");
      localstorage.set('access-token', "");
      localstorage.set('isUserTraverseColony', 0);
      localstorage.set('isStarted', 0);
      $window.localStorage.clear();
      $window.localStorage.removeItem(access-token);
      $ionicHistory.clearCache();
      $ionicHistory.clearHistory();
   };
  </code></pre>
  
  <p>I want to delete the access-token variable from my localStorage, It working fine for browser when i use</p>
  
  <pre><code> $window.localStorage.clear();
   $window.localStorage.removeItem(access-token);
  </code></pre>
  
  <p>But its not working for my App.</p>
  
  <p>here is my localstorage factory</p>
  
  <pre><code>angular.module('starter.controllers').factory('localstorage', ['$window', '$localStorage','$q', function ($window, $localStorage,$q) {
      return {
          set: function (key, value) {
               var deferred = $q.defer();
              $window.localStorage[key] = value;
                   deferred.resolve(1);
                   return deferred.promise;
          },
          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>Any Idea?</p>