Quantcast
Channel: Ionic Forum - Latest posts
Viewing all articles
Browse latest Browse all 228595

Cordova is undefined

$
0
0

Hello all. I'm trying to get the file plugin working; well, ngCordova working in general. I'm having some problems... When running just a simple writeFile execution in the .run function of my module, I get a ReferenceError in my browser that cordova is undefined in my javascript. I included ng-cordova.js, I installed the app I wanted, etc.

I thought, hey, maybe it's because it's Cordova is running in the browser; but I built it to Android and ran it there and it still didn't produce the result.

my code:

var app = angular.module('starter', ['ionic', 'ngCordova'])

.run(function($ionicPlatform, $cordovaFile) {
    $ionicPlatform.ready(function() {
      $cordovaFile.writeFile(cordova.file.dataDirectory, "file.txt", "text", true)
       .then(function (success) {
         // success
       }, function (error) {
         // error
       });
    });
})

(the cordova.file.dataDirectory cordova is undefined)

Any ideas to get this working?


Viewing all articles
Browse latest Browse all 228595

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>