angularjs - What if a file does not exist in local storage for angular.js ngStorage? -


(javascript)

var app = angular.module('app', ['ngstorage']);
app.config(function($scope, $localstorageprovider){
  var userlogstatus = $localstorageprovider.get('userloggedin');
  if (userlogstatus === 'null') {
    $scope.loggedinout = 'partials/pagelink.html';
  } else {
    $scope.loggedinout = 'partials/anotherpage.html';
  }
};

(html)

<div ng-include="'{{loggedinout}}'"></div> 

the code mentioned above not working. value of userlogstatus taken null in javascript because file not exist in local storage of website. please correct code mentioned above , me.

you should correct line:

if (userlogstatus === 'null') 

to this:

if (userlogstatus === null) 

Comments

Popular posts from this blog

How to check data type in C++? -

javascript - Is getTimezoneOffset() stable during daylight saving transition? -

formula - R: how to pass in a reference to the variable in glm or lm? -