javascript - Angular page redirection if returned value is false -
in controller have code logged_status
.
app.controller('dashboardctrl', function($scope, $stateparams, $http) { $scope.displaysn = ''; $scope.studentnumber = sessionstorage.getitem('student_number'); $scope.get_logged_status = sessionstorage.getitem('logged_status'); console.log("dashboard page logged status: " + $scope.get_logged_status); if(!$scope.get_logged_status) { console.log('should redirect because false'); }else{ console.log('should stay because true'); } })
it getting correct value when test value of , log statement, im getting unexpected result. in image below, instead of getting should redirect because false
because $scope.get_logged_status
valued false
, im getting opposite result. please. coding wrong?
please see image here
try :
if($scope.get_logged_status=="false")
maybe item logged_status
in sessionstorage
considered string
not boolean
, returns true
Comments
Post a Comment