angularjs - ngCordova in Angular JS Web Application -
i not expert in angular , have started learning it, trying create responsive form in angularjs web application let me upload file or photo mobile browser (not mobile app). before upload through mobile browser, should check native settings of mobile device (not browser settings settings of mobile device). achieve using ngcordova it's wrapper $cordovafiletransfer. have normal project in eclipse , have included below files in index page(i have stored these files locally in project).
- cordova.js
- file.js
- filetransfer.js
- ng-cordova.js
- ng-cordova.min.js
since using eclipse, tried install thym plugin wouldn't install in work space. below controller code.
angular.module('app').controller( 'cordovactrl', function($scope, $timeout, $cordovafiletransfer) { document.addeventlistener("deviceready", function( $cordovafiletransfer) { alert("inside cordova controller - deviceready"); var filetoupload = ""; var options = { filekey : "sendfile", filename : "angularjsfiletoupload", chunkedmode : false, mimetype : "text/plain" }; var server = "c:/dev/angular file receiver";// temporary path var targetpath = "c:/dev/angular file sender";// temporary path $cordovafiletransfer.upload(server, targetpath, options).then( function() { alert("success"); }, function(err) { alert("error"); }); }, false) });
i understand plugin calls should wrapped in "deviceready"
event. whenever run project below error on browser console.
failed load resource: server responded status of 404 (not found) http://localhost:8080/fileupload/cordova/cordova_plugins.js uncaught typeerror: object #<event> has no method 'upload' app.js:46
i not sure cordova_plugins.js gets fetched from. had read on forum gets generated @ run time (i might wrong). have idea what’s going wrong here? reckon missing on configuration part. possible use ngcordova in web application since supposedly meant mobile development?
try code below
angular.module('app') .controller('cordovactrl', function($scope, $timeout, $cordovafiletransfer) { document.addeventlistener("deviceready", function() { alert("inside cordova controller - deviceready"); var filetoupload = "img.png"; var options = { filekey : "sendfile", filename : "angularjsfiletoupload", chunkedmode : false, mimetype : "text/plain" }; var server = "c:/dev/angular file receiver";// temporary path var targetpath = "c:/dev/angular file sender";// temporary path $cordovafiletransfer.upload(server, targetpath, options) .then(function(result) { alert("success"); }, function(err) { alert("error"); }, function(progress){ alert("in progress"); }); }, false) });
Comments
Post a Comment