2016-10-10 84 views
0

我有这种情况,我ng-repeat我可以得到工作到一定的水平,但任何更深我找不到数组。ng-repeat在certin深度不工作,angularjs

这里是我的代码,同时也低于plunkr:

<div ng-repeat="row in data"> 
    <label ng-repeat="key in keys"> 
     {{row[key]}} 
     <input name="optradio" type="radio"/> 
    </label> 


这PLunker工程确定,但我想,深入到选项层只显示选项1和选项。

http://plnkr.co/edit/xNVVFohA6DeU9nCgi7fQ?p=preview

任何帮助感激地接受。

感谢

回答

0

options是一个数组所以你只需要遍历它

var app = angular.module('app', ['ui.bootstrap']); 
 
app.controller('Ctrl', ['$scope', 
 
    function($scope) { 
 

 
    $scope.data = [{ 
 
     "property": "http://api.mydomain.co.uk/", 
 
     "type": "Selection", 
 
     "options": [{ 
 
     "text": "Option 01", 
 
     "value": "http://api.mydomain.co.uk/O", 
 
     "type": "SelectionOption" 
 
     }, { 
 
     "text": "Option 02", 
 
     "value": "http://api.mydomain.co.uk/L", 
 
     "type": "SelectionOption" 
 
     }] 
 
    }]; 
 

 
    $scope.keys = Object.keys($scope.data[0]); 
 
    } 
 
]);
<!DOCTYPE html> 
 
<html> 
 

 
<head> 
 
    <link data-require="[email protected]" data-semver="3.2.0" rel="stylesheet" href="//maxcdn.bootstrapcdn.com/bootstrap/3.2.0/css/bootstrap.min.css" /> 
 
    <script data-require="[email protected]*" data-semver="1.3.0-beta.5" src="https://code.angularjs.org/1.3.0-beta.5/angular.js"></script> 
 
    <script data-require="[email protected]*" data-semver="0.10.0" src="http://angular-ui.github.io/bootstrap/ui-bootstrap-tpls-0.10.0.js"></script> 
 
    <link rel="stylesheet" href="style.css" /> 
 
    <script src="script.js"></script> 
 
</head> 
 

 
<body ng-app="app" ng-controller="Ctrl"> 
 

 
    <div ng-repeat="row in data"> 
 
    <label ng-repeat="opt in row.options"> 
 
     {{opt.text}} 
 
     <input name="optradio" type="radio" /> 
 
    </label> 
 
    <br> 
 
    </div> 
 

 
</body> 
 

 
</html>

+0

啊很容易,当你知道怎么办。非常感谢。 – wwwredback

+0

@wwwredback没问题的队友!如果它对你有帮助,不要忘了标记它作为答案 – Weedoze