After refreshing the page (e.g., by pressing F5), I noticed that the data in my service gets cleared. Is there a way to prevent this issue without using local storage? It's not a critical feature, but it does disrupt the application flow when users refresh the page, which isn't ideal...
First Controller:
$scope.go = function(location){
classService.currentClass = location;
}
Service:
.service('classService', function () {
var classService = this;
//Initialization
classService.currentClass = null;
});
Second Controller:
.controller('ClassCtrl', function ($scope, classService) {
var currentClass = classService.currentClass;
$scope.className = currentClass.getTeacherClassName();
$scope.classDescription = currentClass.getTeacherClassDescription();
$scope.classCode = currentClass.getTeacherClassCode();
});
I'm still learning programming and AngularJS, so any help would be appreciated!
EDIT: I attempted removing the null initialization, but unfortunately, it did not resolve the issue.