Ruben Alonzo Ruben Alonzo - 10 months ago 57
AngularJS Question

Trouble accesing JSON file with angular

This is the JSON and controllers im using:

JSON Format:



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;


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

So i tried this, and the tomcatLogs don't appear they seem to not get loaded into the html.

What I'm I doing wrong, I'm i doing the wrong call to the JSON file?

Thank you.

Answer Source

Check your controller, you should have 'filesFactory' instead of jsonFactory

It should have parameters correctly,

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


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