2017-07-14 5 views
0

を選択していない、私は今、私はJSONデータを盗んし、それを表示しようとした角度のページを持っている... Firefoxでは、JSONAngularjs - どの要素が

curl localhost:55556 | jq '.' 
[ 
    { 
    "Stack": "prom--1-2-3--jdkfdjkfds", 
    "Url": "http://prom.service.us-east-1.aws.fios.tv", 
    "Members": [ 
     { 
     "Name": "ip1", 
     "Status": "active" 
     }, 
     { 
     "Name": "ip2", 
     "Status": "passive" 
     } 
    ] 
    }, 
    { 
    "Stack": "prom--4-5-6--jdkfdjkfds", 
    "Url": "http://prom456.service.us-east-1.aws.fios.tv", 
    "Members": [ 
     { 
     "Name": "ip3", 
     "Status": "active" 
     }, 
     { 
     "Name": "ip4", 
     "Status": "passive" 
     } 
    ] 
    } 
] 

を吐き出すローカルホスト上で実行されているserivceを持っています私はINspectを見ると、「選択された要素がありません」と表示されます。...

<!doctype html> 
<html> 
    <head> 
    <script src="http://ajax.googleapis.com/ajax/libs/angularjs/1.0.5/angular.min.js"></script> 
    <!--<script src="script.js"></script>--> 

    <meta name="viewport" content="width=device-width, initial-scale=1" charset="utf-8"> 
<link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/css/bootstrap.min.css"> 
<script src="https://ajax.googleapis.com/ajax/libs/jquery/1.12.4/jquery.min.js"></script> 
<script src="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.7/js/bootstrap.min.js"></script> 

<script src="http://code.jquery.com/jquery.min.js"></script> 
<link href="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" rel="stylesheet" type="text/css" /> 
<script src="http://maxcdn.bootstrapcdn.com/bootstrap/3.2.0/js/bootstrap.min.js"></script> 
<script src="https://www.kryogenix.org/code/browser/sorttable/sorttable.js"></script> 
<script> 
    var animalApp = angular.module('animalApp', []); 
    animalApp.controller('animalCtrl', function ($scope, $http){ 
    $http.get('http://localhost:55556').success(function(data) { 
    $scope.animals = data; 
    console.log(data); 
    }); 
}); 
</script> 


<style type="text/css"> 
    #t1 .center_middle { 
    text-align: center; 
    vertical-align: middle; 
    } 
</style> 

</head> 
<body ng-app="animalApp"> 
<h2>My Page</h2> 

<div ng-controller="animalCtrl" > 

    <table class="table table-bordered sortable" style="width: 90%; margin: auto;" id="t1"> 
    <thead> 
     <tr> 
     <th class="text-center">Stack</th> 
     <th class="text-center">Endpoint</th> 
     <th class="text-center">Members</th> 
     <th></th> 
     </tr> 
    </thead> 
    <tr ng-repeat="animal in animals"> 
     <td class="center_middle">{{animal.stack}}</td> 
     <td class="center_middle">{{animal.url}}</td> 
     <td> 
     <table class="table table-bordered sortable" border="1"> 
     <thead> 
      <tr> 
      <th class="text-center">Node</th> 
      <th class="text-center">Status</th> 
      </tr> 
     </thead> 
     <tr ng-repeat="subcat in animal.members"> 
     <td class="center_middle">{{subcat.name}}</td> 
     <td class="center_middle">{{subcat.status}}</td> 
     </tr> 
     </table> 
     </td> 
     <td class="center_middle"><a href="/failover?node={{subcat.name}}&currentstatus={{subcat.status}}">Failover</a></td> 
     <!-- <td class="center_middle"><button type="submit" class="btn btn-default">Failover</button></td> --> 
    </tr> 
    </table> 

</div> 

    </body> 
</html> 

console.logにデータがありません。私はここで間違って何をしていますか?あなたのHTMLファイル内に、彼らは大文字する必要が

+0

にconsole.log(データ)が何を示していますか?それは未定義ですか? – Ero

+0

1)はconsole.log(データ)は、私は大文字のメンバーを使用してみました2)何もない、すなわち何のデータを示していない - あなたは 'HTTPを入力した場合、問題は何が起こるか – mg03

+0

を持続:// localhostを:55556'ブラウザに? – Ero

答えて

0

あなたのプロパティ名は、あなたのJSONに計上されるので

<tr ng-repeat="animal in animals"> 
     <td class="center_middle">{{animal.Stack}}</td> 
     <td class="center_middle">{{animal.Url}}</td> 
     <td> 
     <table class="table table-bordered sortable" border="1"> 
     <thead> 
      <tr> 
      <th class="text-center">Node</th> 
      <th class="text-center">Status</th> 
      </tr> 
     </thead> 
     <tr ng-repeat="subcat in animal.Members"> 
     <td class="center_middle">{{subcat.Name}}</td> 
     <td class="center_middle">{{subcat.Status}}</td> 
     </tr> 
     </table> 
     </td> 
     <td class="center_middle"><a href="/failover?node={{subcat.name}}&currentstatus={{subcat.status}}">Failover</a></td> 
     <!-- <td class="center_middle"><button type="submit" class="btn btn-default">Failover</button></td> --> 
    </tr> 
関連する問題