简体   繁体   中英

ngStorage not accessible in Controller

I am new to Ionic and Angular JS. I have an app.js and a controller.js.

I get connection type in app.js like this

  if(window.Connection){
  $localStorage.connection = navigator.connection.type
         }

When I Try to access $localStorage.connection in my controller.js like this

alert($localStorage.connection);

$$localStorage.connection is empty.

Please how do I Access a value stored in app.js using ngStorage in my Controller.js ?

在实际设备上运行离子应用程序时, ngStorage行为并不持久,存储变量返回空值,因此我建议您使用angular-local-stroage ,这是文档

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM