0

でJSONファイルをaccesing:トラブルこれはJSONであるとコントローラが使用してイム角度

JSONフォーマット:

{"tomcatLogDir":"C:\\apache-tomcat-7.0.70\\logs","tomcatLogs":["1.log","2.log","3.log"]} 

工場:

app.factory('filesFactory', [ '$http', 
             function($http) { 
              return $http.get("http://"+ boxIP +":"+ boxPort +"/monitorTool/rest/toolservice/files") 
               .success(function(data) { 
                return data; 
               }).error(function(err) { 
                return err; 
               }) 
              } ]); 

コントローラー:

app.controller('tomcatLogDirController', [ '$scope', 'filesFactory', 
              function($scope, jsonFactory) { 
               jsonFactory.success(function(data) { 
                 $scope.tomcatDir = data; 
             }); 
            }]); 

をHTML:

<div ng-controller="tomcatLogDirController"> 
     <ul> 
      <li ng-repeat="x in tomcatDir"> 
       <a ng-href="{{'file?name=' + tomcatDir.tomcatLogDir + x.tomcatLogs}}">{{x.tomcatLogs}}</a> 
      </li> 
     </ul> 
    </div> 

私はこれを試しました。そして、tomcatLogsは表示されず、HTMLに読み込まれないようです。

私は間違っていますが、私はJSONファイルを間違って呼び出していますか?

ありがとうございます。

答えて

0

あなたのコントローラを確認し、あなたの代わりにjsonFactory

'filesFactory'を持つべきであることは、正しく

app.controller('tomcatLogDirController', [ '$scope', 'filesFactory', 
              function($scope, filesFactory) { 

EDIT

<ul> 
    <li ng-repeat="x in tomcatDir.tomcatLogs"> 
    <a >{{x}}</a> 
    </li> 
    </ul> 

DEMO

をパラメータを持っている必要があります
+0

ng-repeatでtomcatLogをどのように呼び出すのですか? –

+0

サンプルを確認してください\ – Sajeetharan

+0

「ng-href = "{{'file?name =' + tomcatDir.tomcatLogDir + x.tomcatLogs}」を正しく連結したい場合は、リンクの最後に「1.log」が表示されます –

関連する問題