Amy*_*enn 2 javascript angularjs ionic
在我的app.js中使用离子,我做
angular.module('starter', ['ionic', 'starter.controllers','ngCordova'])
.run(function($ionicPlatform, $localStorage , $cordovaPush) {
$ionicPlatform.ready(function() {
console.log($localStorage);
})
})
Run Code Online (Sandbox Code Playgroud)
但是我得到了错误 Uncaught Error: [$injector:unpr] Unknown provider: $localstorageProvider <- $localstorage
任何想法?这么奇怪..
pie*_*itz 10
你可能错过了依赖!看看例如https://github.com/gsklee/ngStorage.
将它包含在您的项目中并需要ngStorage模块,如下所示:
angular.module('starter', ['ngStorage', 'ionic', 'starter.controllers','ngCordova'])
.run(function($ionicPlatform, $localStorage , $cordovaPush) {
$ionicPlatform.ready(function() {
console.log($localStorage); // edit: capital S
})
})
Run Code Online (Sandbox Code Playgroud)
更改
$localstorage
Run Code Online (Sandbox Code Playgroud)
至
$window.localStorage //S is capitalized
Run Code Online (Sandbox Code Playgroud)
并$window在运行函数中注入依赖项。
| 归档时间: |
|
| 查看次数: |
11773 次 |
| 最近记录: |