I'm new to JS and angular,
I have a currentUser
service in angular... It should set the current user retrieved to the localStorage
to persist it between page refreshes
the service is defined as follows
var currentUserSrvc = function() {
// some logic on how to save the user to localStorage
return {
user: {}
};
};
angular.module('app').factory('currentUser', currentUserSrvc);
I want to override the setters and getters for this service to work with localStorage
... but without adding setters and getters manually
don't mind how the localStorage internals will work
// I just want to use it like
currentUser.user = response.user
// instead of using it like (given that I'll provide a setter and a getter methods)
currentUser.setUser(response.user)
is that possible using angular js ?