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
Post a Comment