2016-09-25 19 views
0

パスをパラメータとする関数はありますか?パスはfile: //storageの形式です。ファイルのパスを読み取るときにコードワイン(イオン)でファイルに書き込んで読み込むにはどうすればよいですか?

+0

これをチェックしてくださいhttp://ngcordova.com/docs/plugins/file/ –

+0

私は実装を手伝ってもらえますか?ファイル://storage/sdcard/1.txt –

+0

パスが動的に変更されています –

答えて

0
angular.module('starter', ['ionic','ngCordova']) 

まず注入するngCordovaモジュール、あなたにこの

run(function($ionicPlatform,$cordovaFile) { 
    $ionicPlatform.ready(function() { 
    console.log(cordova.file); 
    $cordovaFile.readAsText(cordova.file.externalRootDirectory, "1.txt") 
    .then(function (result) { 
    console.log(result); 
    }, function (error) { 
    console.log(error); 
    }); 

ような何かを実行し、コントローラ

.controller('yourCtrl', function($scope,$cordovaFile) { 
ionic.Platform.ready(function() { 
console.log(cordova.file); 
$cordovaFile.readAsText(cordova.file.externalRootDirectory, "1.txt") 
    .then(function (result) { 
    console.log(result); 
    }, function (error) { 
    console.log(error); 
    }); 
}); 
}) 

でこれを使用する場合も、あなたはng-含まれていることを確認してください索引ファイル内のcordova.jsとこの作業のすべてのためのファイル・プラグイン。何か問題があれば教えてください。ありがとう

関連する問題