How to use requestFileSystem with angularJS(ionic)

window.requestFileSystem is not defined if i put it in a service.Code:
var fileModule = angular.module("fileModule",['ionic']); fileModule.factory('filerw',function($window){ var access = $window.requestFileSystem($window.LocalFileSystem.PERSISTENT,0,requestFileSystemSuccessHandler_,fileError); ... });
no matter it’s window or $window,requestFileSystem and LocalFileSystem are undefined.The code works fine in normal JS.

1 Like

I’ve solved. thank you

Can you tell me how you solved it :slight_smile: thank you!

No problem. requestFileSystem doens’t exist until the device is ready, so just a little change.
ionic.Platform.ready = function(){window.requestFileSystem(…)};

hi i have the mistake also,and i wirte like this
.service(‘fileSystem’, function($ionicPlatform,$cordovaFile,$window) {

return {
  	test: function(){
  		return $ionicPlatform.ready(function() { 
  			console.log(ionic.Platform.isReady)
				 	console.log($window.requestFileSystem);
				  	$cordovaFile.readAsText("C:\E5185A4D47C3F9B748257D080020B82612.txt");
  				});
  	}
} 

});
but is also undefined ,could you help me why? thks

1 Like