rootscopesessionstorage

Why do we do this.


I am unable to understand this code.

$rootScope.loginbtn=$sessionStorage.loginbtn; $rootScope.userName=$sessionStorage.userName; $rootScope.admin=$sessionStorage.admin


Solution

  • You have not given many details so an answer will be hard to give.

    From what I can see though, $sessionStorage is a Angular service that acts as a wrapper for the inbuilt browser sessionStorage.

    The code is making the login button, username and admin available on the $rootScope, presumably so they can be accessed in other controllers within the app.

    Provide more details though, and we can give you a better answer