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

java - Run spring boot application error: Cannot instantiate interface org.springframework.context.ApplicationListener -

reactjs - React router and this.props.children - how to pass state to this.props.children -

Excel VBA "Microsoft Windows Common Controls 6.0 (SP6)" Location Changes -