I have some basic angular code grabbing navigation menus for logged in and logged out users and storing the menus in $localStorage
then toggling them to the $rootScope
when the user logs in/out etc.
Below is a simplified version of that code for the purposes of this question.
It seems like one of the lines of code actually results the left-hand-side to be assigned to the right.
$localStorage.navigation = {};
$rootScope.nav = {};
// save the nav menus in local storage
$localStorage.navigation.loggedIn = "nav menu json";
// use local storage to set the rootscope
$rootScope.nav = $localStorage.navigation;
/* should be..
$rootScope.nav = {loggedIn:'nav menu json'};
$localStorage.navigation = {loggedIn:'nav menu json'};
*/
// set the nav menu - Right-hand-assignment???
$rootScope.nav.current = $localStorage.navigation.loggedIn;
/* should be..
$rootScope.nav = { loggedIn:'nav menu json', current: 'nav menu json' };
$localStorage.navigation = { loggedIn:'nav menu json' };
*/
console.log($rootScope.nav.current); // 'nav menu json' as expected
console.log($localStorage.navigation.current); // 'nav menu json', WHAT??!!
/* actually..
$rootScope.nav = { loggedIn:'nav menu json', current: 'nav menu json' };
$localStorage.navigation = { loggedIn:'nav menu json', current: 'nav menu json' };
*/
What in the hell is happening here??