title: how to check null or undefined values in local storage of ionic and redirect to login page?
body: <p>Here is my code here iam checking the null or undefined values or "" like this</p>
  
  <p>i want to check for loggedin or not in ionic v1 app.</p>
  
  <pre><code>$urlRouterProvider.otherwise(function () {
      var items = window.localStorage.getItem('username');
      if (items === undefined || items === null || items.length === 0) {
  
  
          return '/app/login';
  
  
      }
      else {
  
  
          return '/app/search';
  
  
      }
  
  
  });
  </code></pre>
  
  <p>and also tried this </p>
  
  <pre><code> if (localStorage.getItem("username") === null) {
  
        console.log($localStorage.username);
        $scope.username = $localStorage.username;
    }
  </code></pre>
  
  <p>but no luck 
  here am setting the value like this after login</p>
  
  <pre><code>$localStorage.username = $scope.userinfo.username;
  </code></pre>
  
  <p>clearing the local storage items like this </p>
  
  <pre><code>  localStorage.removeItem("username");
    $window.localStorage.clear();
    $ionicHistory.clearCache();
    $ionicHistory.clearHistory();
  </code></pre>
  
  <p>here the problem is every time the app is redirected to login page even though the item username is set or user logged in. What could be the solution please help me iam new to this ionic and angularjs. Thanks in advance.</p>