我想以角度方式訪問ng-repeat
項目的祖父母對象。當父ng-repeat是另一個對象時訪問祖父母ng-repeat對象
我正在努力做到這一點。
正如你可以從下面看到的,我想顯示父對象的文本。
這是一個淡化版本,我正在尋找一種方法來使它像頂級示例一樣工作,或者爲什麼它不起作用。
這是DOM。
<div ng-app ng-controller="MyCtrl">
<!-- this is the one i cannot get working -->
<div>
<div class="copyData" ng-repeat="copy in copyDatabase">
<div ng-repeat="header in masterHeaders">
<div ng-repeat="test in copy.Translations">
set 1: {{test.LanguageAbreviation}}
</div>
</div>
<div>
<!-- this one does work but i need the item from the masterHeaders -->
<div class="copyData" ng-repeat="copy in copyDatabase">
<!-- <div ng-repeat="header in masterHeaders"> -->
<div ng-repeat="test in copy.Translations">
set 2 : {{test.LanguageAbreviation}}
</div>
<!--</div>-->
</div>
</div>
這裏是JSON對象
function MyCtrl($scope) {
$scope.copyDatabase = {
"data": {
"Language": "English",
"Translations": [{
"LanguageID": 308,
"LanguageName": "Arabic - Libya",
"LanguageAbreviation": "ar-LY",
"AvailableLanguages": [{
"ID": 308,
"Name": "Arabic - Libya"
}]
}, {
"LanguageID": 307,
"LanguageName": "Arabic - Egypt",
"LanguageAbreviation": "ar-EG",
"AvailableLanguages": [{
"ID": 307,
"Name": "Arabic - Egypt"
}]
}]
}
}
}
我也做了一個JS搗鼓你們。
http://jsfiddle.net/u7hk0qvj/5/
嗨Kalamarico,感謝您的反饋,不幸thier與我的數據對象的類型-O錯誤,請參閱最新的jsfiddle http://jsfiddle.net/u7hk0qvj/5 /。我希望你能更好地看到我的榜樣 –