I am new on ionic and pretty ashamed to create a topic for something I think is a simple, but i can not figure it out.
I would like to use files in my mobile phone application (read, write, download, upload).
So I go on this web page, http://ngcordova.com/docs/#File, run this command in a terminal:
-cordova plugin add org.apache.cordova.file
-cordova plugin add org.apache.cordova.file-transfer
Now in my controler, i give the $cordovaFile parameter:
Now I am here I don’t know what to do anymore. I think I maybe have to specify something in my ‘index/html’, but I dont know what. I know cordova.file is now installed in my plugin, but how to use it ?
In this file you see the $cordovaFile factory, which you inject in your controller. Basically, if you don’t put this javascript source in your app, the $cordovaFile factory is undefined and your code won’t be able to run. So create a file with the $cordovaFile factory js code and load it with a script tag in your index.html After this, you can inject $cordovaFile in your controller and use exposed functions as per the documentation
var angMod = angular.module('app.dash', ['$cordovaFile']);
angMod.controller('DashCtrl', function($scope, $cordovaFile) {})
For the module where your controller is in, make sure it is injectable Also I think this should work as well (espescially better if you ONLY use the cordovaFile in a single controller:
[$injector:modulerr] Failed to instantiate module starter due to:
Error: [$injector:modulerr] Failed to instantiate module starter.controllers due to:
Error: [$injector:modulerr] Failed to instantiate module $cordovaFile due to:
Error: [$injector:nomod] Module ‘$cordovaFile’ is not available! You either misspelled the module name or forgot to load it. If registering a module ensure that you specify the dependencies as the second argument.
hello. I am a new ionic programmer. I have developed a new project. the project is writing a new png file using $cordovafile. Now I am using Android Phone.
my code.
var v_canvas = document.getElementById(“canvas”);
var v_dataURI = v_canvas.toDataURL().replace( /data:image/png;base64,/, ‘’ );