angular.js - angularjs的run方法中注入了$localStorage,在控制台打印为什么是undifined
世界只因有你
世界只因有你 2017-05-15 17:11:05
0
1
586

我在登录的时候把用户名存在localStorage中,想在stateChangeStart中根据localStorage的信息验证权限,可是我在run方法中注入$localStorage中获取不到$localStorage的值,页面会报错,$localStorage为undifined,这是怎么回事?

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

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