2016-12-12 4 views
-1

私は問題があります:コントローラからファイルを開くには?

私はAngularJSアプリケーションを持っています。私はテーブルといくつかの入力フィールドを持っています。入力フィールドの1つがテキスト領域です。

テーブルからデータを取り出し、入力フィールドに配置するコードが必要です。

ここで、textareaフィールドには明らかに大きなテキストを取ります。
その大きなテキストは、私のデータベースには必要ありません。
テーブルからファイルの名前を取得し、そのファイルが存在する場合はフォルダ内を検索したい場合は、テキストエリアにそのコンテンツを表示する必要があります。

HTMLページ

<label>Script ID:</label> 
    <input 
     name="scriptId" 
     type="text" 
     ng-model="selectedScript.scriptId" 
     value="{{selectedScript.scriptId}}" 
     /> 
    <br /> 

    <label>File Name:</label> 
    <input 
     type="text" 
     ng-model="selectedScript.fileName" 
     value="{{selectedScript.fileName}}" /> 
    <br /> 

<div id="container"> 
     <textarea ng-model="selectedScript.src" 
      value="{{selectedScript.src}}" id="fileInfo"></textarea> 
</div> 

<table class="scripts"> 
    <tr bgcolor="lightgrey"> 
     <th>Script ID</th> 
     <th>File Name</th> 
    </tr> 
    <tr 
     ng-repeat="s in scripts | filter:searchField | orderBy:'scriptId'" 
     ng-click="selectScript(s)" 
     ng-class="getSelectedClass(s)" >   

     <td>{{s.scriptId }}</td> 
     <td>{{s.fileName }}</td> 
    </tr> 
</table> 

とコントローラ

//some function to show what attributes the script has 
$scope.scripts.push({ 
    'scriptId' : selectedScript.scriptId, 
    'fileName' : selectedScript.fileName, 
    'src' : selectedScript.src, 
    'userId' : 1 //hardcoded, for now 
}); 

$scope.selectedScript = {}; 
$scope.selectedRow = null; 

$scope.selectScript = function(script) { 
    $scope.selectedScript = script; 
    //At this point i have the file name, i just need to open the 
    //file, and read it, and push the data to my textarea 
}; 

答えて

1

あなたはJSから、そのようにファイルシステムにアクセスすることはできません。ここで

は、これまでのコードです。

プログラムでには、JSを介してコンピュータのファイルにアクセスできません。

+0

k ...私は別の方法を探します – newbie

+1

幸いにも...! – Mistalis

関連する問題