我正在尝试设计
的数据模型-> Section
-> Sub Section
->Main Element
->Main Element
-> Sub Section
->Main Element
->Main Element
->Main Element
...
这就是我现在所拥有的:
[{
'section': 'market map',
'subsections': ['aa','bb'],
'mainelements':
[
['cc','dd'],
['ee','ff'],
]
}];
这就是我想要的:
-> Market Map
-> aa
->cc
->dd
-> bb
->ee
->ff
这是我的HTML:
<ul>
<li ng-repeat="data in datas">
<ul>
<li ng-repeat="subsection in data.subsections">
<input type="text" ng-model="subsection" size="30" placeholder="add subsection here">
<ul>
<li ng-repeat="mainelement in audit.mainelements">
<input type="text" ng-model="mainelement" size="30" placeholder="add mainelement here">
</li>
</ul>
</li>
</ul>
</li>
</ul>
我明白了:
-> Market Map
-> aa
->[cc, dd]
-> bb
->[ee, ff]
json
结构?答案 0 :(得分:2)
让你的json设计像这样
$scope.datas=[{
'section': 'market map',
'subsections': [{
subSection: 'aa',
mainelements: ['cc','dd']
},{
subSection: 'bb',
mainelements: ['ee','ff']
}]
}];
然后你的html将是
<ul>
<li ng-repeat="data in datas=">
{{data.section}}
<ul>
<li ng-repeat="subsection in data.subsections">
<input type="text" ng-model="subsection.subsection" size="30" placeholder="add subsection here">
<ul>
<li ng-repeat="mainelement in subsection.mainelements">
<input type="text" ng-model="mainelement" size="30" placeholder="add mainelement here">
</li>
</ul>
</li>
</ul>
</li>
</ul>