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ファイルを間違って呼び出していますか?
ありがとうございます。
ng-repeatでtomcatLogをどのように呼び出すのですか? –
サンプルを確認してください\ – Sajeetharan
「ng-href = "{{'file?name =' + tomcatDir.tomcatLogDir + x.tomcatLogs}」を正しく連結したい場合は、リンクの最後に「1.log」が表示されます –