angular.js - $localStorage is injected into the run method of angularjs, why is it undiffed when printed on the console
世界只因有你
世界只因有你 2017-05-15 17:11:05
0
1
607

When I logged in, I stored the username in localStorage and wanted to verify the permissions based on localStorage information in stateChangeStart. However, I injected $localStorage in the run method and could not get the value of $localStorage. The page would report an error, $localStorage As undefined, what's going on?

世界只因有你
世界只因有你

reply all(1)
漂亮男人

localStorage is a property under window, not angularJS. So there is no need to inject it, just use it directly

if( window.localStorage ){
    //do sth...
}

For details, please refer to:

https://developer.mozilla.org...

Latest Downloads
More>
Web Effects
Website Source Code
Website Materials
Front End Template