Getting an error on the console after session reset :
angular.js:11594 TypeError: $sessionStorage.SessionMessage.replace is not a function at Object.<anonymous> (receipt.js:12) at Object.e [as invoke] (angular.js:4182) at z.instance (angular.js:8441) at angular.js:7693 at s (angular.js:331) at v (angular.js:7692) at g (angular.js:7075) at angular.js:6954 at angular.js:1451 at l.$eval (angular.js:14384)
index.js :
//javascript code to disable the browser back button after getting into the receipt page
function preventBack() { window.history.forward(); }
setTimeout("preventBack()", 0);
window.onunload = function () { null };
var app = angular.module('homeapp', ['ngStorage']);
app.controller("HomeController", function ($scope, $sessionStorage, $http) {
$scope.btntext = "Login";
$scope.login = function () {
$scope.mydata = {};
$sessionStorage.SessionMessage = {};
$http.get("http://stagingserver:85/EBSApi/api/Users/GetAllUsers?username=" + $scope.user.username + "&password=" + $scope.user.password + "")
.then(function (response) {
//debugger;
$scope.mydata = JSON.parse(response.data);
$sessionStorage.SessionMessage = {};
angular.forEach($scope.mydata, function (item) {
//debugger;
$scope.stat = "false";
angular.forEach($scope.mydata, function (item) {
if ((item.username == $scope.user.username) && (item.password == $scope.user.password)) {
}
stat = "true";
});
$scope.user.username = "";
$scope.user.password = "";
if (stat == "true" && item.userid == 22) {
//debugger;
$sessionStorage.SessionMessage = response.data;
window.location.href = 'http://stagingserver:85/EBSAjs/Views/Warehouse/receipt.html';
}
else {
alert("Access denied!");
$sessionStorage.reset();
}
})
});
};
$scope.user = {
"username": "",
"password": ""
};
});
receipt.js :
var app = angular.module('AngulardateApp', ['ngStorage', 'angucomplete-alt']);
app.controller('datectrl', function ($scope, $sessionStorage, $http) {
//to display date and time
$scope.currentdate = new Date();
//to get username from the login page and display it in this page
debugger;
var user = JSON.parse($sessionStorage.SessionMessage.replace('[', '').replace(']', ''));
user.username = user.username.substring(0, 1).toUpperCase() + user.username.substring(1, user.username.length);
$scope.username = user.username;
//alert($scope.username);