Just starting out with JS and angular,
I've created a currentUser
service in angular... The goal is to store the current user in the localStorage
so it persists between page refreshes
Here's how the service is defined
var currentUserSrvc = function() {
// logic for saving user to localStorage
return {
user: {}
};
};
angular.module('app').factory('currentUser', currentUserSrvc);
I'm looking to customize the setters and getters for this service to interact with localStorage
... but without manually adding setters and getters
Details of the localStorage functionality are not important
// I just want to be able to do
currentUser.user = response.user
// instead of having to use (if setter and getter methods were provided)
currentUser.setUser(response.user)
Is it possible with angular js?