Error: [$injector:unpr] Unknown provider: $cordovaFileProvider <- $cordovaFile <- AppCtrl
http://errors.angularjs.org/1.3.13/$injector/unpr?p0=%24cordovaFileProvider%20%3C-%20%24cordovaFile%20%3C-%20AppCtrl
at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:8055:20
at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12033:27
at Object.getService [as get] (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12187:53)
at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12038:53
at getService (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12187:53)
at invoke (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12217:78)
at Object.instantiate (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12234:37)
at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:16545:38
at self.appendViewElement (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:47977:42)
at Object.switcher.render (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:46216:65)
I’ve tried the cordovaFile.checkFile function inside of ionic.Platform.ready and all goes well.
ionic.Platform.ready(function() {
// will execute when device is ready, or immediately if the device is already ready.
$cordovaFile.checkFile(cordova.file.dataDirectory, "some_file.txt")
.then(function(success) {
// success
}, function(error) {
alert("file directory: " + cordova.file.dataDirectory)
// error
});
console.log("ready");
});
But if I try to use the same function in another controller I got this error (on my phone):
TypeError: Cannot read property 'dataDirectory' of undefined
at new <anonymous> (file:///android_asset/www/js/controllers.js:142:44)
at invoke (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12110:17)
at Object.instantiate (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:12118:27)
at file:///android_asset/www/lib/ionic/js/ionic.bundle.js:16387:28
at self.appendViewElement (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:47357:24)
at Object.switcher.render (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:45614:41)
at Object.switcher.init (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:45534:20)
at self.render (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:47231:14)
at self.register (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:47189:10)
at updateView (file:///android_asset/www/lib/ionic/js/ionic.bundle.js:52439:23) <ion-nav-view name="AppContent" class="view-container" nav-view-transition="android">