ng-repeat不会迭代嵌套的JSON数组

时间:2015-05-08 11:05:58

标签: angularjs ng-repeat

我有问题。我无法通过ng-repeat来显示我的HTML方面的任何数据。

这是一个带有嵌套数组的JSON obejct的$ http.get HTML:          

<head>
<script data-require="angular.js@1.3.15" data-semver="1.3.15"src="https://code.angularjs.org/1.3.15/angular.js"></script>

<link rel="stylesheet" href="style.css" />
<script src="script.js"></script>

</head>


<body ng-app="stdViewer" ng-controller="stdCtrl">
<h1>Hello Plunker!</h1>



 <div ng-repeat="IKAS_standarder in data">

 {{IKAS_standarder.version}}



 <div ng-repeat="standarder in IKAS_standarder">


  {{standarder.tema}}



   <b>Jobs:</b><br/> 

   </div>
   </div>

   </body>






    </html>

脚本

  (function() {
 var stdCtrl = function($scope, $http) {

var onSucces = function(response) {
  $scope.data = response.data;
};

var onError = function(reason) {
  $scope.error = reason;
};

$http.get("http://46.31.18.93/DataService/IKAS_standard/Sygehuse?  format=json").then(onSucces, onError);
$scope.data = '';
$scope.repoSortOrder = "-SektorID";

};
var app = angular.module("stdViewer", []);
app.controller("stdCtrl", ["$scope", "$http", stdCtrl]);

 }());

我在这里设置了一个pluncker:http://plnkr.co/edit/ERRR8Sj5eG6P4DpRuJx3?p=preview

2 个答案:

答案 0 :(得分:1)

将ng-repeats更改为:

<div ng-repeat="IKAS_standarder in data.IKAS_standarder">...</div>

<div ng-repeat="standarder in IKAS_standarder.standarder">...</div>

对于第一个,您可以将onSuccess方法更改为

$scope.data = response.data.IKAS_standarder

答案 1 :(得分:0)

<div ng-repeat="IKAS_standarder in data">
   <div ng-repeat="std in IKAS_standarder">
     <div ng-repeat="istandarder in std.standarder">
        {{istandarder}}
        <br/>
       </div>
   </div>
</div>

试试这个