【发布时间】:2016-10-05 18:02:02
【问题描述】:
这是我使用的 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 文件的调用?
谢谢。
【问题讨论】:
标签: html angularjs json angularjs-ng-repeat angularjs-controller